[extractor/youtube] Construct fragment list lazily

Building fragment list for all formats take significant time for large videos
This commit is contained in:
pukkandan 2023-03-11 22:46:47 +05:30 committed by Elyse
parent 5ef1a928a7
commit 9fc70f3f6d
1 changed files with 2 additions and 2 deletions

View File

@ -3798,11 +3798,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
**dct,
'format_id': f'{dct["format_id"]}-dashy' if all_formats else dct['format_id'],
'protocol': 'http_dash_segments',
'fragments': [{
'fragments': LazyList({
'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)]
} for range_start in range(0, dct['filesize'], CHUNK_SIZE))
}
if not all_formats:
continue