[ie/twitch] Support --live-from-start

Authored by: bashonly
This commit is contained in:
bashonly 2025-05-17 19:13:46 -05:00
parent abf58dcd6a
commit d664768a01
No known key found for this signature in database
GPG Key ID: 783F096F253D15B0
2 changed files with 11 additions and 2 deletions

View File

@ -205,6 +205,8 @@ class TwitchBaseIE(InfoExtractor):
if fmt.get('vcodec') and fmt['vcodec'].startswith('av01'):
# mpegts does not yet have proper support for av1
fmt['downloader_options'] = {'ffmpeg_args_out': ['-f', 'mp4']}
if self.get_param('live_from_start'):
fmt['downloader_options'] = {'ffmpeg_args': ['-live_start_index', '0']}
return formats
@ -1032,7 +1034,14 @@ class TwitchStreamIE(TwitchBaseIE):
access_token = self._download_access_token(
channel_name, 'stream', 'channelName')
stream_id = stream.get('id') or channel_name
stream_id = stream.get('id')
if self.get_param('live_from_start'):
if stream_id:
return self.url_result(f'https://www.twitch.tv/videos/{stream_id}', TwitchVodIE, stream_id)
self.report_warning('Unable to extract stream ID; cannot download live from start')
if not stream_id:
stream_id = channel_name
formats = self._extract_twitch_m3u8_formats(
'api/channel/hls', channel_name, access_token['value'], access_token['signature'])
self._prefer_source(formats)

View File

@ -470,7 +470,7 @@ def create_parser():
general.add_option(
'--live-from-start',
action='store_true', dest='live_from_start',
help='Download livestreams from the start. Currently only supported for YouTube (Experimental)')
help='Download livestreams from the start. Currently only supported for YouTube (experimental) and Twitch')
general.add_option(
'--no-live-from-start',
action='store_false', dest='live_from_start',