Skip to content

fix: count gallery posts and crossposts in the image duplicate scan - #89

Merged
Toldry merged 4 commits into
masterfrom
claude/gallery-image-scan
Oct 16, 2026
Merged

Toldry merged 4 commits into
masterfrom
claude/gallery-image-scan

Conversation

@Toldry

@Toldry Toldry commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Requested by Querent · project thread

Before: the reply under a crosspost to r/ShitAmericansEat said "I also looked through all 1 image posts made in r/ShitAmericansEat in the last 30 days", although the subreddit had 3 image posts in that period. On the VM, the 2 that were missed turned out to be crossposts. One was a crosspost of an image, whose url is the original post's permalink (/r/ShitAmericansSay/comments/...). The other was a crosspost of a gallery (url = reddit.com/gallery/<other id>, is_gallery None). media_kind returned None for both, so the scan never compared with them or counted them. Gallery posts in general were also skipped. A post whose preview could not be downloaded was dropped from the count silently, logged at DEBUG only.

After: a crosspost's media is read from the original post (crosspost_parent_list[0]), so crossposted images, galleries and videos are compared and counted. A gallery counts as an image post: its first 10 pictures are fingerprinted, and it matches when any of its pictures matches any picture of the source. A gallery source post is scanned too. When a preview cannot be read, the full image is tried. A scan that still cannot read some posts logs a WARNING saying how many.

How: media_field/media_url read media fields from the crosspost parent when there is one, and the crosspost's own fields when the parent was deleted. gallery_image_urls reads media_metadata/gallery_data. fingerprint_post returns a post's fingerprints, with the full-image fallback. best_match compares every pair of pictures. Unit tests cover galleries, crossposted images, galleries and videos, crossposts of text posts, crossposts whose original was deleted, the gallery cap, a gallery source post and the fallback.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PXeu2v7gGePkS9NhaCgwDy

Gallery posts were not image posts to media_kind, so the scan neither
compared with them nor counted them, and a post whose preview could not
be read was dropped silently. Galleries now count as image posts (first
10 pictures, any picture matching), and an unreadable preview falls
back to the full image.

Co-Authored-By: Toldry <toldry@gmail.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PXeu2v7gGePkS9NhaCgwDy
@Toldry Toldry self-assigned this Oct 16, 2026
A crosspost's url is often the original post's permalink, with no
preview, so crossposted images, galleries and videos were skipped and
left out of the reply's image count.

Co-Authored-By: Toldry <toldry@gmail.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PXeu2v7gGePkS9NhaCgwDy
@Toldry Toldry changed the title fix: count gallery posts in the image duplicate scan fix: count gallery posts and crossposts in the image duplicate scan Oct 16, 2026
claude and others added 2 commits October 16, 2026 08:09
Co-Authored-By: Toldry <toldry@gmail.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PXeu2v7gGePkS9NhaCgwDy
…ning

Co-Authored-By: Toldry <toldry@gmail.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PXeu2v7gGePkS9NhaCgwDy
@Toldry
Toldry merged commit c5ecb75 into master Oct 16, 2026
4 checks passed
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.

2 participants