New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[extractor/twitter] Fix unauthenticated extraction #7476
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include fix for Spaces?
It's fine to be in separate PR too
Perfect fix, thank you |
Slightly off-topic, but I just noticed twitter videos can be downloaded by substituting the video id into |
I get a 403 ("bad guest token") |
I just realised that twitter's legacy API does work, if you change the authorisation token to |
Can you access that link in a browser? |
in browser is where I am getting the 403 |
This does work with the legacy API though. (& does not work with graphql.) Hmm |
I found it in the network tab of https://twitter.com/i/videos/tweet/1675748123468267521
What happens if you try to play https://discord.com/channels/807245652072857610/934024231098925078/1126126462630645820? |
Is it useful if it doesn't work with graphql? |
GraphQL may be a lost cause for unauthenticated users, and the legacy API gives more metadata than the syndication endpoint, so yeah it is. It's just a question of which solution will be more stable going forward. |
imo, let's merge this for now and wait for twitter to become stable |
Yeah I think so too. Moving back to legacy API for tweet extraction basically means we have to revert to before 147e62f, and then add additional rate-limit handling. So it will be a whole other PR anyways edit: it is probably worth doing though, since currently twitter broadcasts are still authwalled (and I think they are a still thing) |
Closes yt-dlp#7473 Authored by: bashonly
In response to Twitter authwalling all tweets. The owner claims this is temporary, so maybe we should wait a bit to see if he is telling the truth before merging this.
TODO:Update testsdoneInclude fix for Spaces?separate PRDowngrade 'not all metadata' message severity:donereport_warning
=>to_screen
聽
Closes #7473
Template
Before submitting a pull request make sure you have:
In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check all of the following options that apply:
What is the purpose of your pull request?
Copilot Summary
馃 Generated by Copilot at 7674248
Summary
馃惁馃攧馃殌
Update Twitter extractors to use new APIs and simplify code. This improves the reliability and consistency of downloading videos and audio from Twitter and Twitter Spaces, and reduces code complexity and duplication.
Walkthrough
_call_api
method of theTwitterBaseIE
class and remove the guest token and retry logic (link)_real_extract
method of theTwitterIE
class (link)urllib.error
module to handle HTTP errors from the syndication JSON endpoint (link)extract_from_video_info
function (link)traverse_obj
helper function to access nested fields in the JSON responses more safely and concisely in the_real_extract
method of theTwitterIE
class and theextract_from_video_info
function (link, link, link)mediaDetails
field instead of theextended_entities
field in the syndication JSON response, as the latter may not be complete or present (link)_real_extract
method of theTwitterSpacesIE
class and raise a login required error if not logged in, as the GraphQL API for Twitter Spaces requires authentication (link)