diff options
author | pukkandan <pukkandan@gmail.com> | 2021-01-16 18:10:15 +0530 |
---|---|---|
committer | pukkandan <pukkandan@gmail.com> | 2021-01-16 18:50:48 +0530 |
commit | 30a074c2b666503eb1b09f06d7c7d8fcb1efd058 (patch) | |
tree | 5c575497417db5df51a8533ce41cb8bf0af5e746 /youtube_dlc/extractor/twitch.py | |
parent | 7bc877a20d26ecc441f6ba949b80e361662f97e1 (diff) | |
download | hypervideo-pre-30a074c2b666503eb1b09f06d7c7d8fcb1efd058.tar.lz hypervideo-pre-30a074c2b666503eb1b09f06d7c7d8fcb1efd058.tar.xz hypervideo-pre-30a074c2b666503eb1b09f06d7c7d8fcb1efd058.zip |
Update to ytdl-2021.01.16
Diffstat (limited to 'youtube_dlc/extractor/twitch.py')
-rw-r--r-- | youtube_dlc/extractor/twitch.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/youtube_dlc/extractor/twitch.py b/youtube_dlc/extractor/twitch.py index 503d019de..fc8cb7321 100644 --- a/youtube_dlc/extractor/twitch.py +++ b/youtube_dlc/extractor/twitch.py @@ -17,6 +17,7 @@ from ..compat import ( ) from ..utils import ( clean_html, + dict_get, ExtractorError, float_or_none, int_or_none, @@ -76,14 +77,14 @@ class TwitchBaseIE(InfoExtractor): headers = { 'Referer': page_url, - 'Origin': page_url, + 'Origin': 'https://www.twitch.tv', 'Content-Type': 'text/plain;charset=UTF-8', } response = self._download_json( post_url, None, note, data=json.dumps(form).encode(), headers=headers, expected_status=400) - error = response.get('error_description') or response.get('error_code') + error = dict_get(response, ('error', 'error_description', 'error_code')) if error: fail(error) @@ -137,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: |