[downloader/fragment] Don't fail if the 'Content-Length' header is missing
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Sun, 10 Jan 2016 13:32:53 +0000 (14:32 +0100)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Sun, 10 Jan 2016 13:41:38 +0000 (14:41 +0100)
In some dailymotion videos (like http://www.dailymotion.com/video/x3k0dtv from #8156) the segments URLs don't have the 'Content-Length' header and HttpFD sets the 'totat_bytes' field to None, so we also use '0' in that case (since we do different math operations with it).

youtube_dl/downloader/fragment.py

index 5a64b29eefd9bf7a35f6220efc25bcbd999ce33c..3da554622e77c072427cac997f9acf7f785671dc 100644 (file)
@@ -66,7 +66,7 @@ class FragmentFD(FileDownloader):
             if s['status'] not in ('downloading', 'finished'):
                 return
 
-            frag_total_bytes = s.get('total_bytes', 0)
+            frag_total_bytes = s.get('total_bytes') or 0
             if s['status'] == 'finished':
                 state['downloaded_bytes'] += frag_total_bytes
                 state['frag_index'] += 1