mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-04-27 19:15:53 +00:00
make it actually work tho
Authored by: bashonly
This commit is contained in:
parent
203b302bc9
commit
5e0a911b8a
@ -207,6 +207,7 @@ class TwitchBaseIE(InfoExtractor):
|
|||||||
fmt.setdefault('downloader_options', {}).update({'ffmpeg_args_out': ['-f', 'mp4']})
|
fmt.setdefault('downloader_options', {}).update({'ffmpeg_args_out': ['-f', 'mp4']})
|
||||||
if self.get_param('live_from_start'):
|
if self.get_param('live_from_start'):
|
||||||
fmt.setdefault('downloader_options', {}).update({'ffmpeg_args': ['-live_start_index', '0']})
|
fmt.setdefault('downloader_options', {}).update({'ffmpeg_args': ['-live_start_index', '0']})
|
||||||
|
fmt['is_from_start'] = True
|
||||||
|
|
||||||
return formats
|
return formats
|
||||||
|
|
||||||
@ -921,7 +922,7 @@ class TwitchVideosCollectionsIE(TwitchPlaylistBaseIE):
|
|||||||
playlist_title=f'{channel_name} - Collections')
|
playlist_title=f'{channel_name} - Collections')
|
||||||
|
|
||||||
|
|
||||||
class TwitchStreamIE(TwitchBaseIE):
|
class TwitchStreamIE(TwitchPlaylistBaseIE):
|
||||||
IE_NAME = 'twitch:stream'
|
IE_NAME = 'twitch:stream'
|
||||||
_VALID_URL = r'''(?x)
|
_VALID_URL = r'''(?x)
|
||||||
https?://
|
https?://
|
||||||
@ -984,6 +985,11 @@ class TwitchStreamIE(TwitchBaseIE):
|
|||||||
'skip_download': 'Livestream',
|
'skip_download': 'Livestream',
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
|
_PAGE_LIMIT = 1
|
||||||
|
_OPERATION_NAME = 'FilterableVideoTower_Videos'
|
||||||
|
_ENTRY_KIND = 'video'
|
||||||
|
_EDGE_KIND = 'VideoEdge'
|
||||||
|
_NODE_KIND = 'Video'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def suitable(cls, url):
|
def suitable(cls, url):
|
||||||
@ -997,6 +1003,28 @@ class TwitchStreamIE(TwitchBaseIE):
|
|||||||
TwitchClipsIE))
|
TwitchClipsIE))
|
||||||
else super().suitable(url))
|
else super().suitable(url))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _make_variables(channel_name, broadcast_type, sort):
|
||||||
|
return {
|
||||||
|
'channelOwnerLogin': channel_name,
|
||||||
|
'broadcastType': broadcast_type,
|
||||||
|
'videoSort': sort.upper(),
|
||||||
|
}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _extract_entry(node):
|
||||||
|
if not isinstance(node, dict) or not node.get('id'):
|
||||||
|
return None
|
||||||
|
video_id = node['id']
|
||||||
|
return {
|
||||||
|
'_type': 'url',
|
||||||
|
'ie_key': TwitchVodIE.ie_key(),
|
||||||
|
'id': 'v' + video_id,
|
||||||
|
'url': f'https://www.twitch.tv/videos/{video_id}',
|
||||||
|
'title': node.get('title'),
|
||||||
|
'timestamp': unified_timestamp(node.get('publishedAt')),
|
||||||
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
channel_name = self._match_id(url).lower()
|
channel_name = self._match_id(url).lower()
|
||||||
|
|
||||||
@ -1031,23 +1059,23 @@ class TwitchStreamIE(TwitchBaseIE):
|
|||||||
if not stream:
|
if not stream:
|
||||||
raise UserNotLive(video_id=channel_name)
|
raise UserNotLive(video_id=channel_name)
|
||||||
|
|
||||||
|
timestamp = unified_timestamp(stream.get('createdAt'))
|
||||||
|
|
||||||
|
if self.get_param('live_from_start'):
|
||||||
|
entry = next(self._entries(channel_name, None, 'time'), None)
|
||||||
|
if entry and timestamp <= entry.get('timestamp') or 0:
|
||||||
|
return entry
|
||||||
|
self.report_warning('Unable to extract associated VOD; cannot download live from start')
|
||||||
|
|
||||||
access_token = self._download_access_token(
|
access_token = self._download_access_token(
|
||||||
channel_name, 'stream', 'channelName')
|
channel_name, 'stream', 'channelName')
|
||||||
|
|
||||||
stream_id = stream.get('id')
|
stream_id = stream.get('id') or channel_name
|
||||||
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(
|
formats = self._extract_twitch_m3u8_formats(
|
||||||
'api/channel/hls', channel_name, access_token['value'], access_token['signature'])
|
'api/channel/hls', channel_name, access_token['value'], access_token['signature'])
|
||||||
self._prefer_source(formats)
|
self._prefer_source(formats)
|
||||||
|
|
||||||
view_count = stream.get('viewers')
|
view_count = stream.get('viewers')
|
||||||
timestamp = unified_timestamp(stream.get('createdAt'))
|
|
||||||
|
|
||||||
sq_user = try_get(gql, lambda x: x[1]['data']['user'], dict) or {}
|
sq_user = try_get(gql, lambda x: x[1]['data']['user'], dict) or {}
|
||||||
uploader = sq_user.get('displayName')
|
uploader = sq_user.get('displayName')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user