]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
If --continue is not enabled, set resume_len to zero.
authorMichael Haggerty <mhagger@alum.mit.edu>
Fri, 20 May 2011 06:59:53 +0000 (08:59 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Thu, 15 Sep 2011 17:07:53 +0000 (19:07 +0200)
This corrects the reporting of download progress (which previously
started at a value greater than zero).

youtube-dl

index 685bd2b8c5875ef835a27a2f262dac5d1c7c73ba..e304df5572d02c6841542182761cb75121512367 100755 (executable)
@@ -877,7 +877,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'}
@@ -890,11 +889,14 @@ class FileDownloader(object):
                else:
                        resume_len = 0
 
-               # 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'
+               open_mode = 'wb'
+               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'
+                       else:
+                               resume_len = 0
 
                count = 0
                retries = self.params.get('retries', 0)