aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/downloader/http.py
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2016-09-30 00:49:14 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2016-10-01 14:47:20 +0800
commitd7753d194803086d97ffe47f022c47c906ebcc71 (patch)
treee4169a7301fe2c24747cd334ff2574174364a022 /youtube_dl/downloader/http.py
parenta1001f47fc19adf983859bb281f08a09bd7f7e9b (diff)
[downloader/http] Use write_xattr function for --xattr-set-filesize
Diffstat (limited to 'youtube_dl/downloader/http.py')
-rw-r--r--youtube_dl/downloader/http.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/youtube_dl/downloader/http.py b/youtube_dl/downloader/http.py
index f8b69d186..11294d106 100644
--- a/youtube_dl/downloader/http.py
+++ b/youtube_dl/downloader/http.py
@@ -13,6 +13,9 @@ from ..utils import (
encodeFilename,
sanitize_open,
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:
try:
- import xattr
- xattr.setxattr(tmpfilename, 'user.ytdl.filesize', str(data_len))
- except(OSError, IOError, ImportError) as err:
+ write_xattr(tmpfilename, 'user.ytdl.filesize', str(data_len))
+ except (XAttrUnavailableError, XAttrMetadataError) as err:
self.report_error('unable to set filesize xattr: %s' % str(err))
try: