Skip to content
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

[Twitter] [Enhancement] Bypass blocks by "logging out" #1719

Closed
Scripter17 opened this issue Jul 25, 2021 · 11 comments
Closed

[Twitter] [Enhancement] Bypass blocks by "logging out" #1719

Scripter17 opened this issue Jul 25, 2021 · 11 comments

Comments

@Scripter17
Copy link
Contributor

Admittedly this is probably against Twitter TOS (assuming GDL isn't already), but it'd be nice

Personally I think this should be off by default and a warning should be put in the configuration.rst entry just to be safe

@mikf
Copy link
Owner

mikf commented Aug 2, 2021

I assume by "blocks" you mean Twitter's rate limit, i.e.
[twitter][info] Waiting until … for rate limit reset.?

Resetting this rate limit does not work by simply doing a re-login, it seems. I tried testing this with my own account and the rate limit is still active after logging in a second time. Maybe doing an actual logout instead of just deleting the session cookies does something different, but I doubt it.

What would work, though, is requesting a new guest token when not logged in.

@Scripter17
Copy link
Contributor Author

I mean actual blocks as in [twitter][error] 401 Unauthorized ("You have been blocked from viewing this user's profile.")

@mikf
Copy link
Owner

mikf commented Aug 13, 2021

Should now be possible with commit 52984f7 and the logout option (for lack of a better name). I didn't have a live example to test this on, so please try it out yourself and let me know if it actually works in the real word.

@Scripter17
Copy link
Contributor Author

Sadly no. It detects that I'm blocked but it doesn't log out correctly. Maybe it's the fact that I'm using cookies as well?

gallery-dl -v [account that blocked me] gives the folllowing. (username and stuff redacted)

[gallery-dl][debug] Version 1.18.3
[gallery-dl][debug] Python 3.9.5 - Windows-10-10.0.19042-SP0
[gallery-dl][debug] requests 2.25.1 - urllib3 1.26.4
[gallery-dl][debug] Starting DownloadJob for 'https://twitter.com/[REDACTED]'
[twitter][debug] Using TwitterTimelineExtractor for 'https://twitter.com/[REDACTED]'
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): twitter.com:443
[urllib3.connectionpool][debug] https://twitter.com:443 "GET /i/api/graphql/[REDACTED JUST IN CASE]/UserByScreenName?variables=%7B%22screen_name%22%3A%22[REDACTED]%22%2C%22withHighlightedLabel%22%3Atrue%7D HTTP/1.1" 200 1048
[urllib3.connectionpool][debug] https://twitter.com:443 "GET /i/api/2/timeline/profile/[REDACTED].json?include_profile_interstitial_type=1&include_blocking=1&include_blocked_by=1&include_followed_by=1&include_want_retweets=1&include_mute_edge=1&include_can_dm=1&include_can_media_tag=1&skip_status=1&cards_platform=Web-12&include_cards=1&include_ext_alt_text=true&include_quote_count=true&include_reply_count=1&tweet_mode=extended&include_entities=true&include_user_entities=true&include_ext_media_color=true&include_ext_media_availability=true&send_error_codes=true&simple_quoted_tweet=true&count=100&ext=mediaStats%2ChighlightedLabel&include_tweet_replies=false HTTP/1.1" 401 114
[twitter][info] Retrying API request as guest
[urllib3.connectionpool][debug] https://twitter.com:443 "GET /i/api/2/timeline/profile/[REDACTED].json?include_profile_interstitial_type=1&include_blocking=1&include_blocked_by=1&include_followed_by=1&include_want_retweets=1&include_mute_edge=1&include_can_dm=1&include_can_media_tag=1&skip_status=1&cards_platform=Web-12&include_cards=1&include_ext_alt_text=true&include_quote_count=true&include_reply_count=1&tweet_mode=extended&include_entities=true&include_user_entities=true&include_ext_media_color=true&include_ext_media_availability=true&send_error_codes=true&simple_quoted_tweet=true&count=100&ext=mediaStats%2ChighlightedLabel&include_tweet_replies=false HTTP/1.1" 401 114
[twitter][error] 401 Unauthorized ("You have been blocked from viewing this user's profile.")

My twitter config (minus the cookie file which is in the global part of the config):

"twitter":{
	"skip":"abort:2",
	"text-tweets":true,
	"retweets":true,
	"qouted":true,
	"logout":true,
	"directory":{
		"retweet_id != 0 or author['name']!=user['name']": ["twitter", "{user[name]}", "Retweets"],
		""                                               : ["twitter", "{user[name]}"]
	},
	"filename":{
		"retweet_id != 0 or author['name']!=user['name']": "twitter-{author[name]}-{tweet_id}-{retweet_id}-{num}.{extension}",
		""                                               : "twitter-{author[name]}-{tweet_id}-{num}.{extension}"
	},
	"likes": { "directory": ["Twitter", "{user_likes}", "Likes"] }
}

mikf added a commit that referenced this issue Aug 16, 2021
delete 'auth_token' cookie and cookies.txt path
@mikf
Copy link
Owner

mikf commented Aug 16, 2021

The problem was leaving the auth_token cookie intact, which got fixed in c866fcb. This time I've actually tested this with my own accounts and can confirm that it works and doesn't result in a second 401 Unauthorized error if the profile is public.

@mikf mikf closed this as completed Aug 16, 2021
@Scripter17
Copy link
Contributor Author

Actually, assuming this isn't out of scope, should the block-evasion kick in when searching from:@accounthatblockedyou?

Otherwise it's not possible to get all tweets from someone who blocked you

Not too sure how that should be handled though

@mikf
Copy link
Owner

mikf commented Aug 17, 2021

It can only kick in when Twitter sends an error and gallery-dl can react to that, and I don't think that happens for searches. Presumably Twitter just doesn't show tweets from accounthatblockedyou as search results for blocked accounts.
What you can do in such cases is manually using guest mode by not having a username and/or cookies set, i.e. use -u "" or --cookies "" as command-line options.

@Scripter17
Copy link
Contributor Author

It seems from:@privateaccount doesn't return any tweets even if you follow them, so cookies could just not be used when doing searches

@mikf
Copy link
Owner

mikf commented Aug 21, 2021

Maybe the tweets from @privateaccount get blocked by your account's Search settings?
You can use your config file to disable cookies just for searches, by the way:

        "twitter": {
            "search": {"cookies": null}
        }

@CaptainJawZ
Copy link

I think this feature may not be working anymore, as it seems like sometime during January it stopped prompting the error message saying user was unauthorized and now it prints this message instead
[twitter][info] No results for https://twitter.com/user

@mikf
Copy link
Owner

mikf commented Feb 2, 2022

@CaptainJawZ should work again with a5163e4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants