mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-10 19:47:14 +08:00
save guest token.
This commit is contained in:
parent
77c07d1cc2
commit
3ba6ef6ffb
@ -2816,7 +2816,7 @@ class InfoExtractor(object):
|
||||
""" Return a compat_cookies.SimpleCookie with the cookies for the url """
|
||||
req = sanitized_Request(url)
|
||||
self._downloader.cookiejar.add_cookie_header(req)
|
||||
return compat_cookies.SimpleCookie(req.get_header('Cookie'))
|
||||
return compat_cookies.SimpleCookie(str(req.get_header('Cookie')))
|
||||
|
||||
def _apply_first_set_cookie_header(self, url_handle, cookie):
|
||||
"""
|
||||
|
@ -241,12 +241,18 @@ class TwitterCardIE(TwitterBaseIE):
|
||||
ct0 = self._get_cookies(url).get('ct0')
|
||||
if ct0:
|
||||
headers['csrf_token'] = ct0.value
|
||||
guest_token = self._download_json(
|
||||
'%s/guest/activate.json' % self._API_BASE, video_id,
|
||||
'Downloading guest token', data=b'',
|
||||
headers=headers)['guest_token']
|
||||
guest_token_c = self._get_cookies('http://api.twitter.com/').get('gt')
|
||||
if not guest_token_c:
|
||||
guest_token = self._download_json(
|
||||
'%s/guest/activate.json' % self._API_BASE, video_id,
|
||||
'Downloading guest token', data=b'',
|
||||
headers=headers)['guest_token']
|
||||
self._set_cookie('api.twitter.com', 'gt', guest_token)
|
||||
else:
|
||||
guest_token = guest_token_c.value
|
||||
|
||||
headers['x-guest-token'] = guest_token
|
||||
self._set_cookie('api.twitter.com', 'gt', guest_token)
|
||||
|
||||
config = self._download_json(
|
||||
'%s/videos/tweet/config/%s.json' % (self._API_BASE, video_id),
|
||||
video_id, headers=headers)
|
||||
|
Loading…
x
Reference in New Issue
Block a user