Files

2.4 KiB
Raw Permalink Blame History

Thumbnails

The thumbnails capability provides queued anime poster lookup and a local authenticated cache. Choose Queue, source (AnimeSchedule or provider-url), and allowed HTTPS image hostnames in plugin settings. The default hosts are img.animeschedule.net and s4.anilist.co. Image source URLs are not displayed directly in browser image tags; cached files use same-origin authenticated routes.

Method Behavior
key(title) Validates a 1–200 character title and derives a stable SHA-256 cache key.
request(title, image_url='') Returns an existing cached result as None or submits a Queue job with title and optional provider image URL. No network call occurs in the browser request.
get(title) Returns cached key and authenticated URL, or None; called in a request when rendering Watchlist.
find_image(title) Calls fixed AnimeSchedule metadata search, accepts the first exact normalized identity match and resolves imageVersionRoute against its image base URL. Does not use unrelated titles or arbitrary HTML scraping.
process(payload, progress) Resolves metadata/provider URL, enforces HTTPS/host allowlist/no credentials/default TLS port, refuses redirects, downloads at most 8 MiB, verifies PNG/JPEG/GIF/WebP signatures, and atomically publishes the cache plus metadata.

A job has two progress steps: metadata lookup and cache publication. Network timeouts are bounded; unsupported/SVG/HTML content and unexpected hosts fail the job. Existing cached images remain available when a later service is unavailable. Titles/metadata live in plugin_data; files are private under <data_dir>/plugins/thumbnails/<hash>.image.

GET /plugins/thumbnails/ shows the cache and a request form. POST / requires content.write/CSRF and submits a download (or reports a cached result). GET /images/<key> accepts exactly a lowercase 64-digit SHA-256 key, requires an enabled plugin and authenticated access, and returns only the registered cache file/MIME type. Missing files/keys return 404. index(), request_image(), image() and service() adapt these routes.

Title normalization helpers are adapted from Kaizoku and retain season identity, including ordinal season spelling. This initial plugin provides AnimeSchedule and explicit provider images; it does not include Kaizoku's AniDB title-dump fallback. Another thumbnail implementation can replace it through Watchlist's service selector.