[twitch] Fix api calls (Closes #10654, closes #10660)

pull/8/head
Sergey M․ 8 years ago
parent c035dba19e
commit 95be29e1c6
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

@ -32,6 +32,7 @@ class TwitchBaseIE(InfoExtractor):
_API_BASE = 'https://api.twitch.tv' _API_BASE = 'https://api.twitch.tv'
_USHER_BASE = 'https://usher.ttvnw.net' _USHER_BASE = 'https://usher.ttvnw.net'
_LOGIN_URL = 'http://www.twitch.tv/login' _LOGIN_URL = 'http://www.twitch.tv/login'
_CLIENT_ID = 'jzkbprff40iqj646a697cyrvl0zt2m6'
_NETRC_MACHINE = 'twitch' _NETRC_MACHINE = 'twitch'
def _handle_error(self, response): def _handle_error(self, response):
@ -44,15 +45,9 @@ class TwitchBaseIE(InfoExtractor):
expected=True) expected=True)
def _call_api(self, path, item_id, note): def _call_api(self, path, item_id, note):
headers = {
'Referer': 'http://api.twitch.tv/crossdomain/receiver.html?v=2',
'X-Requested-With': 'XMLHttpRequest',
}
for cookie in self._downloader.cookiejar:
if cookie.name == 'api_token':
headers['Twitch-Api-Token'] = cookie.value
response = self._download_json( response = self._download_json(
'%s/%s' % (self._API_BASE, path), item_id, note) '%s/%s' % (self._API_BASE, path), item_id, note,
headers={'Client-ID': self._CLIENT_ID})
self._handle_error(response) self._handle_error(response)
return response return response

Loading…
Cancel
Save