mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-12 10:11:07 +01:00
parent
2a23d92d9e
commit
e389d172b6
@ -3630,6 +3630,7 @@ def _needs_live_processing(self, live_status, duration):
|
|||||||
return live_status
|
return live_status
|
||||||
|
|
||||||
def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, live_status, duration):
|
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), []
|
itags, stream_ids = collections.defaultdict(set), []
|
||||||
itag_qualities, res_qualities = {}, {0: None}
|
itag_qualities, res_qualities = {}, {0: None}
|
||||||
q = qualities([
|
q = qualities([
|
||||||
@ -3642,6 +3643,13 @@ def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, l
|
|||||||
streaming_formats = traverse_obj(streaming_data, (..., ('formats', 'adaptiveFormats'), ...))
|
streaming_formats = traverse_obj(streaming_data, (..., ('formats', 'adaptiveFormats'), ...))
|
||||||
all_formats = self._configuration_arg('include_duplicate_formats')
|
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:
|
for fmt in streaming_formats:
|
||||||
if fmt.get('targetDurationSec'):
|
if fmt.get('targetDurationSec'):
|
||||||
continue
|
continue
|
||||||
@ -3771,17 +3779,12 @@ def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, l
|
|||||||
if single_stream and dct.get('ext'):
|
if single_stream and dct.get('ext'):
|
||||||
dct['container'] = dct['ext'] + '_dash'
|
dct['container'] = dct['ext'] + '_dash'
|
||||||
|
|
||||||
CHUNK_SIZE = 10 << 20
|
|
||||||
if dct['filesize']:
|
if dct['filesize']:
|
||||||
yield {
|
yield {
|
||||||
**dct,
|
**dct,
|
||||||
'format_id': f'{dct["format_id"]}-dashy' if all_formats else dct['format_id'],
|
'format_id': f'{dct["format_id"]}-dashy' if all_formats else dct['format_id'],
|
||||||
'protocol': 'http_dash_segments',
|
'protocol': 'http_dash_segments',
|
||||||
'fragments': LazyList({
|
'fragments': build_fragments(dct),
|
||||||
'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 not all_formats:
|
if not all_formats:
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user