mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-08-21 14:51:12 +02:00
[twitter:card] Generalize base API URL
This commit is contained in:
parent
b6b2ccb72f
commit
77053237c5
@ -108,6 +108,8 @@ class TwitterCardIE(TwitterBaseIE):
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
_API_BASE = 'https://api.twitter.com/1.1'
|
||||||
|
|
||||||
def _parse_media_info(self, media_info, video_id):
|
def _parse_media_info(self, media_info, video_id):
|
||||||
formats = []
|
formats = []
|
||||||
for media_variant in media_info.get('variants', []):
|
for media_variant in media_info.get('variants', []):
|
||||||
@ -149,7 +151,7 @@ def _extract_mobile_formats(self, username, video_id):
|
|||||||
main_script, 'bearer token')
|
main_script, 'bearer token')
|
||||||
# https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-show-id
|
# https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-show-id
|
||||||
api_data = self._download_json(
|
api_data = self._download_json(
|
||||||
'https://api.twitter.com/1.1/statuses/show/%s.json' % video_id,
|
'%s/statuses/show/%s.json' % (self._API_BASE, video_id),
|
||||||
video_id, 'Downloading API data',
|
video_id, 'Downloading API data',
|
||||||
headers={
|
headers={
|
||||||
'Authorization': 'Bearer ' + bearer_token,
|
'Authorization': 'Bearer ' + bearer_token,
|
||||||
@ -237,13 +239,13 @@ def _real_extract(self, url):
|
|||||||
if ct0:
|
if ct0:
|
||||||
headers['csrf_token'] = ct0.value
|
headers['csrf_token'] = ct0.value
|
||||||
guest_token = self._download_json(
|
guest_token = self._download_json(
|
||||||
'https://api.twitter.com/1.1/guest/activate.json', video_id,
|
'%s/guest/activate.json' % self._API_BASE, video_id,
|
||||||
'Downloading guest token', data=b'',
|
'Downloading guest token', data=b'',
|
||||||
headers=headers)['guest_token']
|
headers=headers)['guest_token']
|
||||||
headers['x-guest-token'] = guest_token
|
headers['x-guest-token'] = guest_token
|
||||||
self._set_cookie('api.twitter.com', 'gt', guest_token)
|
self._set_cookie('api.twitter.com', 'gt', guest_token)
|
||||||
config = self._download_json(
|
config = self._download_json(
|
||||||
'https://api.twitter.com/1.1/videos/tweet/config/%s.json' % video_id,
|
'%s/videos/tweet/config/%s.json' % (self._API_BASE, video_id),
|
||||||
video_id, headers=headers)
|
video_id, headers=headers)
|
||||||
track = config['track']
|
track = config['track']
|
||||||
vmap_url = track.get('vmapUrl')
|
vmap_url = track.get('vmapUrl')
|
||||||
|
Loading…
Reference in New Issue
Block a user