1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-25 11:41:52 +00:00

[Youtube] Construct dash formats with range query

See yt-dlp/yt_dlp#6369
This commit is contained in:
pukkandan 2023-02-28 23:03:44 +05:30 committed by dirkf
parent f7ce98a21e
commit 3da17834a4

View file

@ -1694,8 +1694,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
if n_response is None: if n_response is None:
# give up if descrambling failed # give up if descrambling failed
break break
fmt['url'] = update_url( for fmt_dct in traverse_obj(fmt, (None, (None, ('fragments', Ellipsis))), expected_type=dict):
parsed_fmt_url, query_update={'n': [n_response]}) fmt_dct['url'] = update_url(
fmt_dct['url'], query_update={'n': [n_response]})
# from yt-dlp, with tweaks # from yt-dlp, with tweaks
def _extract_signature_timestamp(self, video_id, player_url, ytcfg=None, fatal=False): def _extract_signature_timestamp(self, video_id, player_url, ytcfg=None, fatal=False):
@ -2047,10 +2048,19 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
if no_video: if no_video:
dct['abr'] = tbr dct['abr'] = tbr
if no_audio or no_video: if no_audio or no_video:
dct['downloader_options'] = { CHUNK_SIZE = 10 << 20
# Youtube throttles chunks >~10M # avoid Youtube throttling
'http_chunk_size': 10485760, dct.update({
} 'protocol': 'http_dash_segments',
'fragments': [{
'url': update_url_query(dct['url'], {
'range': '{0}-{1}'.format(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'): if dct.get('ext'):
dct['container'] = dct['ext'] + '_dash' dct['container'] = dct['ext'] + '_dash'
formats.append(dct) formats.append(dct)