]> jfr.im git - yt-dlp.git/commitdiff
[extractor/youtube] Construct dash formats with `range` query
authorpukkandan <redacted>
Tue, 28 Feb 2023 17:33:44 +0000 (23:03 +0530)
committerpukkandan <redacted>
Tue, 28 Feb 2023 17:44:37 +0000 (23:14 +0530)
Closes #6369

yt_dlp/extractor/youtube.py

index be82bc6899cfb28df5810cad112bf66bfe5985fe..0227a1f83c51f5f14e267028dfcb915858a38b77 100644 (file)
@@ -3776,10 +3776,19 @@ def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, l
             if no_video:
                 dct['abr'] = tbr
             if no_audio or no_video:
-                dct['downloader_options'] = {
-                    # Youtube throttles chunks >~10M
-                    'http_chunk_size': 10485760,
-                }
+                CHUNK_SIZE = 10 << 20
+                dct.update({
+                    'request_data': b'x',
+                    'protocol': 'http_dash_segments',
+                    'fragments': [{
+                        'url': update_url_query(dct['url'], {
+                            'range': f'{range_start}-{min(range_start + CHUNK_SIZE - 1, dct["filesize"])}'
+                        })
+                    } for range_start in range(0, dct['filesize'], CHUNK_SIZE)]
+                } if dct['filesize'] else {
+                    'downloader_options': {'http_chunk_size': CHUNK_SIZE}  # No longer useful?
+                })
+
                 if dct.get('ext'):
                     dct['container'] = dct['ext'] + '_dash'