[twitch:clips] Add access token query to download URLs (closes #29136)

pull/29174/merge
phlip 2021-05-28 11:01:59 +10:00 committed by Sergey M․
parent 24297a42ef
commit e13a01061d
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D
1 changed files with 20 additions and 0 deletions

View File

@ -49,6 +49,7 @@ class TwitchBaseIE(InfoExtractor):
'ChannelCollectionsContent': '07e3691a1bad77a36aba590c351180439a40baefc1c275356f40fc7082419a84', 'ChannelCollectionsContent': '07e3691a1bad77a36aba590c351180439a40baefc1c275356f40fc7082419a84',
'StreamMetadata': '1c719a40e481453e5c48d9bb585d971b8b372f8ebb105b17076722264dfa5b3e', 'StreamMetadata': '1c719a40e481453e5c48d9bb585d971b8b372f8ebb105b17076722264dfa5b3e',
'ComscoreStreamingQuery': 'e1edae8122517d013405f237ffcc124515dc6ded82480a88daef69c83b53ac01', 'ComscoreStreamingQuery': 'e1edae8122517d013405f237ffcc124515dc6ded82480a88daef69c83b53ac01',
'VideoAccessToken_Clip': '36b89d2507fce29e5ca551df756d27c1cfe079e2609642b4390aa4c35796eb11',
'VideoPreviewOverlay': '3006e77e51b128d838fa4e835723ca4dc9a05c5efd4466c1085215c6e437e65c', 'VideoPreviewOverlay': '3006e77e51b128d838fa4e835723ca4dc9a05c5efd4466c1085215c6e437e65c',
'VideoMetadata': '226edb3e692509f727fd56821f5653c05740242c82b0388883e0c0e75dcbf687', 'VideoMetadata': '226edb3e692509f727fd56821f5653c05740242c82b0388883e0c0e75dcbf687',
} }
@ -924,6 +925,17 @@ class TwitchClipsIE(TwitchBaseIE):
raise ExtractorError( raise ExtractorError(
'This clip is no longer available', expected=True) 'This clip is no longer available', expected=True)
access_token = self._download_gql(
video_id, [{
'operationName': 'VideoAccessToken_Clip',
'variables': {
'slug': video_id,
},
}],
'Downloading access token GraphQL')
access_token = try_get(
access_token, lambda x: x[0]['data']['clip']['playbackAccessToken'])
formats = [] formats = []
for option in clip.get('videoQualities', []): for option in clip.get('videoQualities', []):
if not isinstance(option, dict): if not isinstance(option, dict):
@ -931,6 +943,14 @@ class TwitchClipsIE(TwitchBaseIE):
source = url_or_none(option.get('sourceURL')) source = url_or_none(option.get('sourceURL'))
if not source: if not source:
continue continue
if access_token:
source = "%s%s%s" % (
source,
"&" if "?" in source else "?",
compat_urllib_parse_urlencode({
"sig": access_token.get('signature'),
"token": access_token.get('value'),
}))
formats.append({ formats.append({
'url': source, 'url': source,
'format_id': option.get('quality'), 'format_id': option.get('quality'),