Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Backups
youtube-dl
Commits
77053237
Unverified
Commit
77053237
authored
Jun 03, 2018
by
Sergey M․
Browse files
[twitter:card] Generalize base API URL
parent
b6b2ccb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
youtube_dl/extractor/twitter.py
youtube_dl/extractor/twitter.py
+5
-3
No files found.
youtube_dl/extractor/twitter.py
View file @
77053237
...
...
@@ -108,6 +108,8 @@ class TwitterCardIE(TwitterBaseIE):
},
]
_API_BASE
=
'https://api.twitter.com/1.1'
def
_parse_media_info
(
self
,
media_info
,
video_id
):
formats
=
[]
for
media_variant
in
media_info
.
get
(
'variants'
,
[]):
...
...
@@ -149,7 +151,7 @@ class TwitterCardIE(TwitterBaseIE):
main_script
,
'bearer token'
)
# https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-show-id
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'
,
headers
=
{
'Authorization'
:
'Bearer '
+
bearer_token
,
...
...
@@ -237,13 +239,13 @@ class TwitterCardIE(TwitterBaseIE):
if
ct0
:
headers
[
'csrf_token'
]
=
ct0
.
value
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
''
,
headers
=
headers
)[
'guest_token'
]
headers
[
'x-guest-token'
]
=
guest_token
self
.
_set_cookie
(
'api.twitter.com'
,
'gt'
,
guest_token
)
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
)
track
=
config
[
'track'
]
vmap_url
=
track
.
get
(
'vmapUrl'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment