Auto-resolved topic title + poster image (WithMetadata)#32
Merged
Conversation
Add a WithMetadata tracker capability that resolves a real display title and a poster/preview image from a topic URL. RuTracker and LostFilm implement it (og:image preferred, with postImg/main_poster fallbacks; titles cleaned of site suffixes). - Resolved best-effort (fail-open, 8s timeout) when a topic is added, so a new topic shows a real name + image immediately instead of a 'RuTracker topic 123' placeholder. - Scheduler self-heals the stored title on each check when a plugin's Check reports a different DisplayName (displayNamePersister -> Topics.UpdateDisplayName), upgrading existing placeholder topics. - New GET /trackers/preview?url= powers the AddTopic form preview card. - image_url persisted (migration 0005); rendered as a graceful <img> that hides on load error -- no fake fallback (per no-synthetic-data). The real title makes the tracker name in the topic display obsolete; the existing source badge already conveys it. Stacked on feat/client-base-folder-category (PR #30).
RuTracker serves windows-1251; the raw <title> bytes were invalid UTF-8 -> rendered as mojibake and made the scheduler's UpdateDisplayName fail with Postgres SQLSTATE 22021. Decode cp1251 -> UTF-8 in cleanTitle, but only when the bytes aren't already valid UTF-8 (keeps ASCII / UTF-8 sources untouched). LostFilm's <title> is a full SEO sentence; prefer og:title, handle the en-dash site suffix, and trim to the leading show-name segment so the display name is just e.g. 'Пацаны (The Boys)'. Adds cp1251-decode and bloated-title unit tests.
CodeQL go/request-forgery (critical): ResolveMetadata fetched the raw user-supplied URL, letting a crafted topic URL redirect the request to an arbitrary host. Rebuild the fetch URL from the trusted host (p.domain) plus the parsed numeric topic id (RuTracker) / series slug (LostFilm), so the destination host can never be user-controlled. Mirrors the existing safe patterns in Download (dl.php) and SeasonCatalog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Auto-resolves a real topic title + poster image per tracker (#2/#3/#5 of the topic-metadata design). Rebased onto
mainafter the folder PR (#30) merged; supersedes the auto-closed #31.WithMetadatacapabilityResolveMetadata(url) -> {Title, ImageURL}, implemented by RuTracker and LostFilm. Resolved best-effort (fail-open, 8s) at add-time, re-persisted on each check (self-heal), and exposed viaGET /trackers/previewfor the add-form preview card.topics.image_urlmigration0005; frontend<PosterImage>hides cleanly on load error (no fake fallback).Tracker fixes (found by live testing)
<title>bytes were invalid UTF-8, rendering as mojibake and making the self-heal write fail with PostgresSQLSTATE 22021. Now decoded cp1251→UTF-8 (only when not already valid UTF-8).<title>is a full SEO sentence — now prefersog:title, handles the en-dash site suffix, and trims to the show name (e.g.Пацаны (The Boys)).Verified live
Test Plan
ResolveMetadata+ cp1251-decode + bloated-title unit tests (RuTracker, LostFilm)image_urlgo build/vet/test ./...green (35 pkgs)typecheck+ 31 tests +buildgreen