]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[downloader/fragment] Make speed more smooth
authorSergey M․ <dstftw@gmail.com>
Sat, 5 Mar 2016 23:36:52 +0000 (05:36 +0600)
committerSergey M․ <dstftw@gmail.com>
Sat, 5 Mar 2016 23:36:52 +0000 (05:36 +0600)
At the beginning of every segment there was a drop to Unknown speed due to timeslice being too small to calculate speed.
Now last speed from the previous fragment is used.

youtube_dl/downloader/fragment.py

index 5bc99492bc7b90abdc5c133b3f6c573d54fe9ed3..a5bae96699e0b0f81fd11deab4900fe5ed8b820d 100644 (file)
@@ -99,7 +99,8 @@ class FragmentFD(FileDownloader):
                     state['eta'] = self.calc_eta(
                         start, time_now, estimated_size,
                         state['downloaded_bytes'])
-                state['speed'] = s.get('speed')
+                state['speed'] = s.get('speed') or ctx.get('speed')
+                ctx['speed'] = state['speed']
                 ctx['prev_frag_downloaded_bytes'] = frag_downloaded_bytes
             self._hook_progress(state)