aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormain() <main@ehvag.eu.org>2021-01-14 13:41:44 +0100
committerGitHub <noreply@github.com>2021-01-14 12:41:44 +0000
commit879866a2304c3b0bbbb048feb4253431f0219aa3 (patch)
treed093f1d5e34e5b5056b1c4bd1cc1f89b9854085e
parent8e5477d036319adee98a6a7f95fc0ba09bb7b28c (diff)
downloadyoutube-dl-879866a2304c3b0bbbb048feb4253431f0219aa3.tar.xz
[twitch] Set OAuth token for GraphQL requests using auth-token cookie (#27790)
Co-authored-by: remitamine <remitamine@gmail.com>
-rw-r--r--youtube_dl/extractor/twitch.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/youtube_dl/extractor/twitch.py b/youtube_dl/extractor/twitch.py
index c4fd2f686..a7867f4d3 100644
--- a/youtube_dl/extractor/twitch.py
+++ b/youtube_dl/extractor/twitch.py
@@ -138,13 +138,17 @@ class TwitchBaseIE(InfoExtractor):
self._sort_formats(formats)
def _download_base_gql(self, video_id, ops, note, fatal=True):
+ headers = {
+ 'Content-Type': 'text/plain;charset=UTF-8',
+ 'Client-ID': self._CLIENT_ID,
+ }
+ gql_auth = self._get_cookies('https://gql.twitch.tv').get('auth-token')
+ if gql_auth:
+ headers['Authorization'] = 'OAuth ' + gql_auth.value
return self._download_json(
'https://gql.twitch.tv/gql', video_id, note,
data=json.dumps(ops).encode(),
- headers={
- 'Content-Type': 'text/plain;charset=UTF-8',
- 'Client-ID': self._CLIENT_ID,
- }, fatal=fatal)
+ headers=headers, fatal=fatal)
def _download_gql(self, video_id, ops, note, fatal=True):
for op in ops: