Skip to content

Auto-resolved topic title + poster image (WithMetadata)#32

Merged
artyomsv merged 3 commits into
mainfrom
feat/topic-metadata
May 30, 2026
Merged

Auto-resolved topic title + poster image (WithMetadata)#32
artyomsv merged 3 commits into
mainfrom
feat/topic-metadata

Conversation

@artyomsv

Copy link
Copy Markdown
Owner

Summary

Auto-resolves a real topic title + poster image per tracker (#2/#3/#5 of the topic-metadata design). Rebased onto main after the folder PR (#30) merged; supersedes the auto-closed #31.

WithMetadata capability

ResolveMetadata(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 via GET /trackers/preview for the add-form preview card. topics.image_url migration 0005; frontend <PosterImage> hides cleanly on load error (no fake fallback).

Tracker fixes (found by live testing)

  • RuTracker serves windows-1251 — raw <title> bytes were invalid UTF-8, rendering as mojibake and making the self-heal write fail with Postgres SQLSTATE 22021. Now decoded cp1251→UTF-8 (only when not already valid UTF-8).
  • LostFilm <title> is a full SEO sentence — now prefers og:title, handles the en-dash site suffix, and trims to the show name (e.g. Пацаны (The Boys)).

Verified live

  • LostFilm preview returns clean title + correct poster. ✅
  • RuTracker resolves when the page is fetchable; it's Cloudflare-gated for guests (reliable with a RuTracker account / cfsolver) — documented, not a blocker.

Test Plan

  • ResolveMetadata + cp1251-decode + bloated-title unit tests (RuTracker, LostFilm)
  • Repo tests updated for image_url
  • Backend go build/vet/test ./... green (35 pkgs)
  • Frontend typecheck + 31 tests + build green

artyomsv added 3 commits May 30, 2026 10:40
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.
@artyomsv artyomsv merged commit 816061d into main May 30, 2026
7 checks passed
@artyomsv artyomsv deleted the feat/topic-metadata branch May 30, 2026 08:57
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.

1 participant