Consider the file downloaded if the size differs in less than 100 bytes (fixes issue...
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>
Sat, 31 Jul 2010 23:15:43 +0000 (01:15 +0200)
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>
Sun, 31 Oct 2010 10:28:36 +0000 (11:28 +0100)
youtube-dl

index cf0336e56c7bfc377eefcbcb339ca788801243a0..6be25baa4345764b8ab6bec2e401ecc62c874550 100755 (executable)
@@ -542,8 +542,15 @@ class FileDownloader(object):
                                                        raise
                                        else:
                                                # Examine the reported length
-                                               if content_length is not None and long(content_length) == resume_len:
-                                                       # The file had already been fully downloaded
+                                               if (content_length is not None and
+                                                   resume_len - 100 < long(content_length) < resume_len + 100):
+                                                       # The file had already been fully downloaded.
+                                                       # Explanation to the above condition: in issue #175 it was revealed that
+                                                       # YouTube sometimes adds or removes a few bytes from the end of the file,
+                                                       # changing the file size slightly and causing problems for some users. So
+                                                       # I decided to implement a suggested change and consider the file
+                                                       # completely downloaded if the file size differs less than 100 bytes from
+                                                       # the one in the hard drive.
                                                        self.report_file_already_downloaded(filename)
                                                        return True
                                                else: