mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 04:10:23 +00:00
[twitch] Pass api_token along with every request (Closes #3986)
This commit is contained in:
parent
a0090691d0
commit
0d103de3b0
@ -34,7 +34,15 @@ def _handle_error(self, response):
|
||||
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…
Reference in New Issue
Block a user