[extractor/common] Fix duration per dash segment (closes #11868)
authorSergey M․ <dstftw@gmail.com>
Sat, 28 Jan 2017 22:36:53 +0000 (05:36 +0700)
committerSergey M․ <dstftw@gmail.com>
Sat, 28 Jan 2017 22:36:53 +0000 (05:36 +0700)
youtube_dl/extractor/common.py

index dce8c7d0d5ad389aa84bf84f25731a2e680e91e3..a3048fb595ea62f1648cc98cdfcb77eda3bef6fb 100644 (file)
@@ -1751,14 +1751,16 @@ class InfoExtractor(object):
                             # Example: https://www.youtube.com/watch?v=iXZV5uAYMJI
                             # or any YouTube dashsegments video
                             fragments = []
-                            s_num = 0
-                            for segment_url in representation_ms_info['segment_urls']:
-                                s = representation_ms_info['s'][s_num]
+                            segment_index = 0
+                            timescale = representation_ms_info['timescale']
+                            for s in representation_ms_info['s']:
+                                duration = float_or_none(s['d'], timescale)
                                 for r in range(s.get('r', 0) + 1):
                                     fragments.append({
-                                        'url': segment_url,
-                                        'duration': float_or_none(s['d'], representation_ms_info['timescale']),
+                                        'url': representation_ms_info['segment_urls'][segment_index],
+                                        'duration': duration,
                                     })
+                                    segment_index += 1
                             representation_ms_info['fragments'] = fragments
                         # NB: MPD manifest may contain direct URLs to unfragmented media.
                         # No fragments key is present in this case.