diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2023-03-12 14:46:09 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2023-03-12 14:47:05 +0530 |
commit | e389d172b6f42e4f332ae679dc48543fb7b9b61d (patch) | |
tree | 5f88dcf04d919489b89919a28ccae8f169ac2661 | |
parent | 2a23d92d9ec44a0168079e38bcf3d383e5c4c7bb (diff) | |
download | hypervideo-pre-e389d172b6f42e4f332ae679dc48543fb7b9b61d.tar.lz hypervideo-pre-e389d172b6f42e4f332ae679dc48543fb7b9b61d.tar.xz hypervideo-pre-e389d172b6f42e4f332ae679dc48543fb7b9b61d.zip |
Fix 2a23d92d9ec44a0168079e38bcf3d383e5c4c7bb
Closes #6517
-rw-r--r-- | yt_dlp/extractor/youtube.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 4165d795c..d7cd0dc62 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -3630,6 +3630,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): return live_status def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, live_status, duration): + CHUNK_SIZE = 10 << 20 itags, stream_ids = collections.defaultdict(set), [] itag_qualities, res_qualities = {}, {0: None} q = qualities([ @@ -3642,6 +3643,13 @@ class YoutubeIE(YoutubeBaseInfoExtractor): streaming_formats = traverse_obj(streaming_data, (..., ('formats', 'adaptiveFormats'), ...)) all_formats = self._configuration_arg('include_duplicate_formats') + def build_fragments(f): + return LazyList({ + 'url': update_url_query(f['url'], { + 'range': f'{range_start}-{min(range_start + CHUNK_SIZE - 1, f["filesize"])}' + }) + } for range_start in range(0, f['filesize'], CHUNK_SIZE)) + for fmt in streaming_formats: if fmt.get('targetDurationSec'): continue @@ -3771,17 +3779,12 @@ class YoutubeIE(YoutubeBaseInfoExtractor): if single_stream and dct.get('ext'): dct['container'] = dct['ext'] + '_dash' - CHUNK_SIZE = 10 << 20 if dct['filesize']: yield { **dct, 'format_id': f'{dct["format_id"]}-dashy' if all_formats else dct['format_id'], 'protocol': 'http_dash_segments', - '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)) + 'fragments': build_fragments(dct), } if not all_formats: continue |