1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2025-04-19 21:37:40 +00:00
This commit is contained in:
GitHub Merge Button 2011-09-10 02:09:16 -07:00
commit 4fa223ca6c

View File

@ -509,6 +509,16 @@ class FileDownloader(object):
except (UnicodeEncodeError), err:
self.to_screen(u'[download] The file has already been downloaded')
def report_file_partly_downloaded(self, file_name):
"""Report file has already been partly downloaded."""
msg = (u'ERROR: %s has already been partly downloaded; '
u'please select either --continue or --no-continue')
try:
self.to_screen(msg % file_name)
except (UnicodeEncodeError), err:
self.to_screen(msg % u'The file')
def report_unable_to_resume(self):
"""Report it was impossible to resume download."""
self.to_screen(u'[download] Unable to resume')
@ -664,7 +674,6 @@ class FileDownloader(object):
tmpfilename = self.temp_name(filename)
stream = None
open_mode = 'wb'
# Do not include the Accept-Encoding header
headers = {'Youtubedl-no-compression': 'True'}
@ -677,11 +686,18 @@ class FileDownloader(object):
else:
resume_len = 0
open_mode = 'wb'
# Request parameters in case of being able to resume
if self.params.get('continuedl', False) and resume_len != 0:
self.report_resuming_byte(resume_len)
request.add_header('Range','bytes=%d-' % resume_len)
open_mode = 'ab'
if resume_len != 0:
if self.params.get('continuedl', False):
self.report_resuming_byte(resume_len)
request.add_header('Range','bytes=%d-' % resume_len)
open_mode = 'ab'
elif self.params.get('continuedl') is None:
self.report_file_partly_downloaded(filename)
return False
else:
resume_len = 0
count = 0
retries = self.params.get('retries', 0)
@ -2807,7 +2823,10 @@ if __name__ == '__main__':
filesystem.add_option('-w', '--no-overwrites',
action='store_true', dest='nooverwrites', help='do not overwrite files', default=False)
filesystem.add_option('-c', '--continue',
action='store_true', dest='continue_dl', help='resume partially downloaded files', default=False)
action='store_true', dest='continue_dl', help='resume partially downloaded files', default=None)
filesystem.add_option('--no-continue',
action='store_false', dest='continue_dl',
help='do not resume partially downloaded files (restart from beginning)')
filesystem.add_option('--cookies',
dest='cookiefile', metavar='FILE', help='file to dump cookie jar to')
filesystem.add_option('--no-part',