From 2d1655493f097a72d520f91211183e89a196f8e0 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Thu, 9 Mar 2023 22:09:23 +0530 Subject: [PATCH] [extractor/youtube] Bypass throttling for `-f17` and related cleanup Thanks @AudricV for the finding --- yt_dlp/extractor/youtube.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 2f83f0654..394634757 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -3766,13 +3766,11 @@ def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, l if mime_mobj: dct['ext'] = mimetype2ext(mime_mobj.group(1)) dct.update(parse_codecs(mime_mobj.group(2))) - no_audio = dct.get('acodec') == 'none' - no_video = dct.get('vcodec') == 'none' - if no_audio: - dct['vbr'] = tbr - if no_video: - dct['abr'] = tbr - if no_audio or no_video: + + single_stream = 'none' in (dct.get('acodec'), dct.get('vcodec')) + if single_stream and dct.get('ext'): + dct['container'] = dct['ext'] + '_dash' + if single_stream or itag == '17': CHUNK_SIZE = 10 << 20 dct.update({ 'protocol': 'http_dash_segments', @@ -3781,13 +3779,10 @@ def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, l '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 itag != '17' and dct['filesize'] else { + 'downloader_options': {'http_chunk_size': CHUNK_SIZE} }) - if dct.get('ext'): - dct['container'] = dct['ext'] + '_dash' - if itag: itags[itag].add(('https', dct.get('language'))) stream_ids.append(stream_id)