aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2018-08-03 22:43:06 +0700
committerSergey M․ <dstftw@gmail.com>2018-08-03 22:44:31 +0700
commitcb1c3a3c07b2afe854ecd8c97f77d8f62720d7a4 (patch)
tree84025e82286f1b6a063354c37c0a305f61e97cc5 /youtube_dl/extractor
parent48afc6ca3ea8b666b0af24b0d9f424917d134d1b (diff)
[twitch] Update cliend id and modernize (closes #17126)
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/twitch.py22
1 files changed, 8 insertions, 14 deletions
diff --git a/youtube_dl/extractor/twitch.py b/youtube_dl/extractor/twitch.py
index cbb735403..b39972b1e 100644
--- a/youtube_dl/extractor/twitch.py
+++ b/youtube_dl/extractor/twitch.py
@@ -8,7 +8,6 @@ import json
from .common import InfoExtractor
from ..compat import (
- compat_HTTPError,
compat_kwargs,
compat_parse_qs,
compat_str,
@@ -39,7 +38,7 @@ class TwitchBaseIE(InfoExtractor):
_USHER_BASE = 'https://usher.ttvnw.net'
_LOGIN_FORM_URL = 'https://www.twitch.tv/login'
_LOGIN_POST_URL = 'https://passport.twitch.tv/login'
- _CLIENT_ID = 'jzkbprff40iqj646a697cyrvl0zt2m6'
+ _CLIENT_ID = 'kimne78kx3ncx6brgo4mv6wki5h1ko'
_NETRC_MACHINE = 'twitch'
def _handle_error(self, response):
@@ -84,20 +83,15 @@ class TwitchBaseIE(InfoExtractor):
headers = {
'Referer': page_url,
'Origin': page_url,
- 'Content-Type': 'text/plain;charset=UTF-8'
+ 'Content-Type': 'text/plain;charset=UTF-8',
}
- try:
- response = self._download_json(
- post_url, None, note,
- data=json.dumps(form).encode(),
- headers=headers)
- except ExtractorError as e:
- if isinstance(e.cause, compat_HTTPError) and e.cause.code == 400:
- response = self._parse_json(
- e.cause.read().decode('utf-8'), None)
- fail(response.get('error_description') or response.get('error_code'))
- raise
+ 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')
+ if error:
+ fail(error)
if 'Authenticated successfully' in response.get('message', ''):
return None, None