mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-25 03:32:05 +00:00
[downloader/http] Use write_xattr function for --xattr-set-filesize
This commit is contained in:
parent
a1001f47fc
commit
d7753d1948
2 changed files with 5 additions and 9 deletions
|
@ -283,12 +283,6 @@ def _real_main(argv=None):
|
||||||
'key': 'ExecAfterDownload',
|
'key': 'ExecAfterDownload',
|
||||||
'exec_cmd': opts.exec_cmd,
|
'exec_cmd': opts.exec_cmd,
|
||||||
})
|
})
|
||||||
if opts.xattr_set_filesize:
|
|
||||||
try:
|
|
||||||
import xattr
|
|
||||||
xattr # Confuse flake8
|
|
||||||
except ImportError:
|
|
||||||
parser.error('setting filesize xattr requested but python-xattr is not available')
|
|
||||||
external_downloader_args = None
|
external_downloader_args = None
|
||||||
if opts.external_downloader_args:
|
if opts.external_downloader_args:
|
||||||
external_downloader_args = compat_shlex_split(opts.external_downloader_args)
|
external_downloader_args = compat_shlex_split(opts.external_downloader_args)
|
||||||
|
|
|
@ -13,6 +13,9 @@ from ..utils import (
|
||||||
encodeFilename,
|
encodeFilename,
|
||||||
sanitize_open,
|
sanitize_open,
|
||||||
sanitized_Request,
|
sanitized_Request,
|
||||||
|
write_xattr,
|
||||||
|
XAttrMetadataError,
|
||||||
|
XAttrUnavailableError,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,9 +182,8 @@ class HttpFD(FileDownloader):
|
||||||
|
|
||||||
if self.params.get('xattr_set_filesize', False) and data_len is not None:
|
if self.params.get('xattr_set_filesize', False) and data_len is not None:
|
||||||
try:
|
try:
|
||||||
import xattr
|
write_xattr(tmpfilename, 'user.ytdl.filesize', str(data_len))
|
||||||
xattr.setxattr(tmpfilename, 'user.ytdl.filesize', str(data_len))
|
except (XAttrUnavailableError, XAttrMetadataError) as err:
|
||||||
except(OSError, IOError, ImportError) as err:
|
|
||||||
self.report_error('unable to set filesize xattr: %s' % str(err))
|
self.report_error('unable to set filesize xattr: %s' % str(err))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue