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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[extractor/twitter] Migrate to GraphQL, handle auth errors #6957
Conversation
yt_dlp/extractor/twitter.py
Outdated
|
||
if result.get('errors'): | ||
errors = traverse_obj(result, ('errors', ..., 'message', {str})) | ||
if first_attempt and any('bad guest token' in error.lower() for error in errors): |
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.
if first_attempt and any('bad guest token' in error.lower() for error in errors): | |
if first_attempt and not self.is_logged_in and any('bad guest token' in error.lower() for error in errors): |
correct? Otherwise it may unnecessarily try twice when logged in.
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.
it wouldn't hurt to add, but I don't think it's necessary as we are already never passing a guest token when logged in
EDIT: ended up refactoring the error handling and adding it
Closes yt-dlp#6763 Authored by: bashonly
Sometime in early April, Twitter changed something and broke our age-gate bypass for sensitive media. We had been using a "deprecated" bearer token to get around the age-restriction, which has now been rendered effectively useless. And because the legacy API (that we were using by default for tweet extraction) only returns a 404 without any further info for age-restricted tweets, this site change has necessitated that tweet extraction defaults to the GraphQL API instead, since GraphQL returns error info that can be used to detect when to
raise_login_required
.The change in default behavior makes the
force_graphql
extractor-arg pointless, so this PR replaces it with thelegacy_api
extractor-arg, which has the opposite effect, and could be used as a fallback in case of potential future GraphQL breakage. Also, the legacy API is still used by other subclasses, so legacy API code cannot be removed/replaced entirely.Closes #6763
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?