diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2015-01-25 04:49:44 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2015-01-25 04:49:44 +0100 |
commit | 881e6a1f5c47a65348879f817ad833081e8c5ada (patch) | |
tree | b00cf8678eb48bc96815d32a58d13721151ba652 /youtube_dl/downloader/http.py | |
parent | baeaeffce550b23848983cd281f173a7906cd7f9 (diff) |
Add --xattr-set-filesize option (Fixes #1348)
Diffstat (limited to 'youtube_dl/downloader/http.py')
-rw-r--r-- | youtube_dl/downloader/http.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/youtube_dl/downloader/http.py b/youtube_dl/downloader/http.py index 4db50ee90..8a1d578d5 100644 --- a/youtube_dl/downloader/http.py +++ b/youtube_dl/downloader/http.py @@ -157,6 +157,14 @@ class HttpFD(FileDownloader): except (OSError, IOError) as err: self.report_error('unable to open for writing: %s' % str(err)) return False + + 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: + self.report_error('unable to set filesize xattr: %s' % str(err)) + try: stream.write(data_block) except (IOError, OSError) as err: |