Browse Source

[twitch] Pass api_token along with every request (Closes #3986)

totalwebcasting
Sergey M․ 9 years ago
parent
commit
0d103de3b0
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      youtube_dl/extractor/twitch.py

+ 9
- 1
youtube_dl/extractor/twitch.py View File

@ -34,7 +34,15 @@ class TwitchBaseIE(InfoExtractor):
expected=True)
def _download_json(self, url, video_id, note='Downloading JSON metadata'):
response = super(TwitchBaseIE, self)._download_json(url, video_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
request = compat_urllib_request.Request(url, headers=headers)
response = super(TwitchBaseIE, self)._download_json(request, video_id, note)
self._handle_error(response)
return response


Loading…
Cancel
Save