mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 09:01:43 +00:00
[extractor/twitch] Extract original size thumbnail (#6629)
Authored by: JC-Chung
This commit is contained in:
parent
1ea15603d8
commit
80b732b7a9
@ -179,6 +179,14 @@ def _download_access_token(self, video_id, token_kind, param_name):
|
|||||||
video_id, ops,
|
video_id, ops,
|
||||||
'Downloading %s access token GraphQL' % token_kind)['data'][method]
|
'Downloading %s access token GraphQL' % token_kind)['data'][method]
|
||||||
|
|
||||||
|
def _get_thumbnails(self, thumbnail):
|
||||||
|
return [{
|
||||||
|
'url': re.sub(r'\d+x\d+(\.\w+)($|(?=[?#]))', r'0x0\g<1>', thumbnail),
|
||||||
|
'preference': 1,
|
||||||
|
}, {
|
||||||
|
'url': thumbnail,
|
||||||
|
}] if thumbnail else None
|
||||||
|
|
||||||
|
|
||||||
class TwitchVodIE(TwitchBaseIE):
|
class TwitchVodIE(TwitchBaseIE):
|
||||||
IE_NAME = 'twitch:vod'
|
IE_NAME = 'twitch:vod'
|
||||||
@ -460,15 +468,13 @@ def _extract_info_gql(self, info, item_id):
|
|||||||
is_live, thumbnail = True, None
|
is_live, thumbnail = True, None
|
||||||
else:
|
else:
|
||||||
is_live = False
|
is_live = False
|
||||||
for p in ('width', 'height'):
|
|
||||||
thumbnail = thumbnail.replace('{%s}' % p, '0')
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': vod_id,
|
'id': vod_id,
|
||||||
'title': info.get('title') or 'Untitled Broadcast',
|
'title': info.get('title') or 'Untitled Broadcast',
|
||||||
'description': info.get('description'),
|
'description': info.get('description'),
|
||||||
'duration': int_or_none(info.get('lengthSeconds')),
|
'duration': int_or_none(info.get('lengthSeconds')),
|
||||||
'thumbnail': thumbnail,
|
'thumbnails': self._get_thumbnails(thumbnail),
|
||||||
'uploader': try_get(info, lambda x: x['owner']['displayName'], compat_str),
|
'uploader': try_get(info, lambda x: x['owner']['displayName'], compat_str),
|
||||||
'uploader_id': try_get(info, lambda x: x['owner']['login'], compat_str),
|
'uploader_id': try_get(info, lambda x: x['owner']['login'], compat_str),
|
||||||
'timestamp': unified_timestamp(info.get('publishedAt')),
|
'timestamp': unified_timestamp(info.get('publishedAt')),
|
||||||
@ -1053,7 +1059,7 @@ def _real_extract(self, url):
|
|||||||
'display_id': channel_name,
|
'display_id': channel_name,
|
||||||
'title': title,
|
'title': title,
|
||||||
'description': description,
|
'description': description,
|
||||||
'thumbnail': thumbnail,
|
'thumbnails': self._get_thumbnails(thumbnail),
|
||||||
'uploader': uploader,
|
'uploader': uploader,
|
||||||
'uploader_id': channel_name,
|
'uploader_id': channel_name,
|
||||||
'timestamp': timestamp,
|
'timestamp': timestamp,
|
||||||
|
Loading…
Reference in New Issue
Block a user