X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fdownloader%2Fhttp.py;h=49170cf9d47634602efe7832b235e4a751e25817;hb=12832049170e8b3bd457706f49e8e09de12a368c;hp=4db50ee90ecbde017eeaf380232f5a6edafcbd38;hpb=e1554a407d8953d0ec4fabec7f5a3b3906d1029b;p=youtube-dl diff --git a/youtube_dl/downloader/http.py b/youtube_dl/downloader/http.py index 4db50ee90..49170cf9d 100644 --- a/youtube_dl/downloader/http.py +++ b/youtube_dl/downloader/http.py @@ -3,6 +3,9 @@ from __future__ import unicode_literals import os import time +from socket import error as SocketError +import errno + from .common import FileDownloader from ..compat import ( compat_urllib_request, @@ -99,6 +102,11 @@ class HttpFD(FileDownloader): resume_len = 0 open_mode = 'wb' break + except SocketError as e: + if e.errno != errno.ECONNRESET: + # Connection reset is no problem, just retry + raise + # Retry count += 1 if count <= retries: @@ -157,6 +165,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: