add ffmpeg argument to avoid keepalive request failure in downloading live video

This commit is contained in:
kclauhk 2024-09-10 15:12:58 +08:00
parent 6a3d3dca93
commit bf4aa73fb7

View file

@ -96,11 +96,15 @@ def _real_extract(self, url):
'url': caption.get('file'), 'url': caption.get('file'),
'name': caption.get('label'), 'name': caption.get('label'),
}) })
is_live = bool(video.get('is_live'))
for source in video.get('sources', []): for source in video.get('sources', []):
if media_url := url_or_none(source.get('file')): if media_url := url_or_none(source.get('file')):
if determine_ext(media_url) == 'm3u8': if determine_ext(media_url) == 'm3u8':
hls_fmts, hls_subs = self._extract_m3u8_formats_and_subtitles( hls_fmts, hls_subs = self._extract_m3u8_formats_and_subtitles(
media_url, video['mediaid'], fatal=None) media_url, video['mediaid'], fatal=None)
if is_live:
for f in hls_fmts:
f['downloader_options'] = {'ffmpeg_args_out': ['-http_persistent', '0']}
formats.extend(hls_fmts) formats.extend(hls_fmts)
self._merge_subtitles(hls_subs, target=subtitles) self._merge_subtitles(hls_subs, target=subtitles)
else: else:
@ -127,10 +131,10 @@ def _real_extract(self, url):
'episode_number': ('episodeNumber', {int_or_none}), 'episode_number': ('episodeNumber', {int_or_none}),
'cast': ('cast', {lambda v: v.split(',') if v else None}), 'cast': ('cast', {lambda v: v.split(',') if v else None}),
'duration': ('duration', {float_or_none}), 'duration': ('duration', {float_or_none}),
'is_live': ('is_live', {lambda v: bool(v)}),
'webpage_url': ('mediaid', {lambda v: url + (f'?episodeId={v}' if v not in url else '')}), 'webpage_url': ('mediaid', {lambda v: url + (f'?episodeId={v}' if v not in url else '')}),
'thumbnail': ('image', {lambda v: url_or_none(v) if not thumbnails else None}), 'thumbnail': ('image', {lambda v: url_or_none(v) if not thumbnails else None}),
}), }),
'is_live': is_live,
'thumbnails': thumbnails, 'thumbnails': thumbnails,
'formats': formats, 'formats': formats,
'subtitles': subtitles, 'subtitles': subtitles,