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

[reddit] implement Reddit Mobile share links #4693

Merged
merged 1 commit into from Oct 25, 2023
Merged

[reddit] implement Reddit Mobile share links #4693

merged 1 commit into from Oct 25, 2023

Conversation

ghost
Copy link

@ghost ghost commented Oct 21, 2023

Reddit Mobile app has implemented a new share URL format relatively recently (somewhere around August), which looks like this:

https://www.reddit.com/r/analog/s/hKrTTvFVwZ

This is an obfuscated personalized tracking URL which redirects to a submission:

https://www.reddit.com/r/analog/comments/179exao/photographing_the_recent_annular_eclipse_with_a/?share_id=okPOBW_OzrDClMSiZSLjV&utm_content=1&utm_medium=ios_app&utm_name=ioscss&utm_source=share&utm_term=1

This PR adds a minimal redirect extractor for this URL format.

@mikf
Copy link
Owner

mikf commented Oct 21, 2023

Nice. Thanks for this.
You should run make to update docs/supportedsites.md for this new extractor.

I wonder if it would somehow be possible to translate a share ID like /s/hKrTTvFVwZ to its submission ID /comments/179exao without a round-trip to Reddit.

@ghost
Copy link
Author

ghost commented Oct 22, 2023

I wonder if it would somehow be possible to translate a share ID like /s/hKrTTvFVwZ to its submission ID /comments/179exao without a round-trip to Reddit.

So do I. The share button generates a new URL every time (for instance, for this submission it also generated /r/analog/s/wtyoA8OBdx and /r/analog/s/kKWXLI8d0W), and it doesn't seem like they have anything obvious in common:

base62 decode
>>> for frag in ["hKrTTvFVwZ", "wtyoA8OBdx", "kKWXLI8d0W"]:
...     format(base62.decode(frag), "b")
...
'100000100100001100101110110010111010111111001001001011100011'
'101100010000110101110100111111000101101101001000111011011001'
'100010110100001101111001011011000110001111000111010000111100'

(it should be noted that each share URL seems to be unique to subreddit; if you replace the subreddit with another, it will redirect to that subreddit itself)

So I think probably not.

@mikf mikf merged commit 6766877 into mikf:master Oct 25, 2023
9 checks passed
@ghost ghost deleted the reddit-mobile-redirect branch October 26, 2023 14:02
@ghost
Copy link
Author

ghost commented Dec 13, 2023

Update: starting today(?), Reddit seems to 403 these links quite aggressively. Tests still work, so it's probably only relevant to logged-in clients.

$ gallery-dl https://www.reddit.com/r/analog/s/hKrTTvFVwZ
[reddit][error] HttpError: '403 Blocked' for 'https://www.reddit.com/r/analog/s/hKrTTvFVwZ'

@Hrxn
Copy link
Contributor

Hrxn commented Dec 13, 2023

A 403? Uh, probably just intermittent Reddit server issues..

@ghost
Copy link
Author

ghost commented Dec 14, 2023

Nevermind! These mobile share links seem to need browser cookies to work properly now. I set those up and they do work again. So, no further action needed at this time, I guess.

@Hrxn It looks more like an anti-crawl measure, tbh. Reddit also 403s curl requests without cookies for mobile share links now, and I don't think they did at the time this PR was submitted.

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

Successfully merging this pull request may close these issues.

3 participants