sopel-irc / sopel-reddit

A reddit plugin for Sopel IRC bots.
Other
0 stars 1 forks source link

Different `i.redd.it` link format for anonymous users #5

Closed dgw closed 1 year ago

dgw commented 1 year ago

Reddit apparently (as of writing; who knows what'll happen in a month or a year) uses a different submission-page layout for anonymous page viewers—neither the classic "old" design nor the oft-maligned redesign they've been working on for the last 5+ years, though the browse views (frontpage, subreddits, etc.) still use the redesign for anon clients.

This logged-out layout comes with alternate clickthrough image URLs for Reddit-hosted images, of the format: https://i.redd.it/post-slug-with-hyphens-instead-of-underscores-v0-imageID.jpg?s=hexadecimalsignature

Linking one of these images (e.g. https://i.redd.it/my-neighbor-keeps-parking-in-front-of-my-garage-v0-u41q9gy0f5ya1.jpg?s=a902227dd3ec0952a91d214a2d4c086cd283319f) in view of the reddit plugin will (silently) fail to fetch the source post, because the current pattern captures more than just the image ID in the image group:

https://github.com/sopel-irc/sopel-reddit/blob/3b40b86d85b084ae663a709d407377167b6af72c/sopel_reddit/__init__.py#L38

Presumably the v0 element could be nonzero; maybe they are working on letting people edit/replace images uploaded directly.

While preview.redd.it links from galleries are also affected by this (the s param is added to the other format, resolution, etc. GET args), looking up the source gallery based on the URL of one image from it isn't currently supported, so that isn't (yet) an issue in itself.