Skip to content

feat(metadata): read banner, thumb, clear art, disc art and every backdrop from local sidecars - #2321

Merged
Quick104 merged 21 commits into
mainfrom
feat/local-image-types
Oct 12, 2026
Merged

Quick104 merged 21 commits into
mainfrom
feat/local-image-types

Conversation

@Quick104

@Quick104 Quick104 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #216
Validation tasks: none

Kodi- and Jellyfin-style libraries keep more artwork beside the media than Silo reads: a banner, a landscape thumb, clear art, disc art, and several backdrops (fanart-1.jpg, extrafanart/). Silo stores only a poster, one backdrop and a logo per item, so it ignores the rest. Jellyfin apps connected to Silo ask for Banner, Thumb, Art, Disc and indexed Backdrop images and get nothing useful back. Thumb returns the backdrop, Banner, Art and Disc return 404, BackdropImageTags has at most one entry, and every Backdrop/{index} returns the first backdrop. Their banner and thumb views stay blank.

This change stores those images, finds them under the names Kodi and Jellyfin use, and serves them on /api/v2 movie and series detail and on the Jellyfin-compatible API.

Approach

  • Storage. media_items gets banner, thumb, clear art and disc slots. Each has a served path and a source path, and banner and thumb also get a thumbhash, following the poster, backdrop and logo columns. Backdrops after the first go in a new media_item_backdrops table, ordered by ordinal. media_items.backdrop_* stays the primary backdrop, so existing readers are unchanged. The image cache, the revision GC triggers, the artwork sweep surfaces, and item and folder deletion all cover the new slots and table. A cache job for an extra backdrop targets its row (item_backdrop). Its local cache key carries a hash of the sidecar's path, so two sidecars with the same bytes never share a key, a backdrop keeps its key when its row moves, and re-caching one backdrop never deletes another's files.
  • Discovery (internal/metadata/nfo). The names follow Jellyfin's LocalImageProvider: banner; landscape, then thumb; clearart (art.jpg stays a backdrop); disc, then cdart, then discart, for movies only. Each name can also take the media file's basename as a prefix, which wins over the plain name. After the named backdrops, which keep fix(metadata): find local artwork the way Kodi and Jellyfin name it, and keep it #2300's order so the primary doesn't change, come fanart-N (or Kodi's fanartN), background-N, art-N and backdropN. Each numbered family stops after three missing numbers in a row. Every image in extrafanart/ follows. An item keeps at most 20 backdrops. Jellyfin's backdrops/ folder holds theme videos, so it is not read. fix(metadata): find local artwork the way Kodi and Jellyfin name it, and keep it #2300's case-insensitive listing covers all of these names.
  • Refresh. These images only come from sidecars today, so a refresh carries them over from the stored item. A refresh that searched for local artwork drops a slot or backdrop only when the sidecar's folder answers and the file is no longer offered; a removed extrafanart folder counts once the folder holding it answers. This is fix(metadata): find local artwork the way Kodi and Jellyfin name it, and keep it #2300's rule for the poster, so an unmounted share keeps the images. Plugin image kinds banner, thumb, clearart and disc now map to these slots instead of falling back to poster. No plugin sends them yet.
  • Native API. getCatalogItem adds banner_url, banner_thumbhash, thumb_url, thumb_thumbhash, clearart_url, disc_url and backdrop_urls (every backdrop, backdrop_url first) for movies and series. getImageCapabilities reports extended_item_artwork and the widths of the new types. /api/v1, cards and lists are unchanged.
  • Jellyfin compatibility. Movies and series list Banner, Thumb, Art and Disc in ImageTags and every backdrop in BackdropImageTags, on lists and detail. The tags are seeded by cached path, so they change only when the image changes. /Items/{id}/Images/{Banner,Thumb,Art,Disc} serve the images. Thumb still falls back to the backdrop and then the poster. Backdrop/{index} serves that position and returns 404 past the last backdrop.

Season banners, thumbs and backdrops, and NFO <thumb aspect=…> art, are left for follow-ups (below). The architecture doc lists both under known limitations.

User manual: Silo-Server/siloserver.org#183 (draft, stacked on siloserver.org#166) adds the new names to Add artwork.

Validation

  • go build, gofmt, go vet and make lint-changed (against main) are clean. The web, settings-binding, playback, route-inventory, ledger, scenario, offline-route, OpenAPI, contract, fixture, web-type, local-path and case-collision checks pass.
  • make test-go: the only failures are two real-FFmpeg tests in internal/mediasample, which fail the same way on fix(metadata): find local artwork the way Kodi and Jellyfin name it, and keep it #2300's branch with this host's FFmpeg.
  • DB-backed suites for migrations, catalog, metadata, jellycompat, apiv2, imagecache, taskmanager, storagetransition and sections pass against a freshly migrated PostgreSQL. Six new tests are added to scripts/ci/db-contracts.txt and pass through its runner. They cover the migration's Up and Down (including the GC triggers and job constraints), slot write-back, backdrop row identity and GC queueing, the folder-delete reference check over the new columns, provider backfill and repair of the new slots, and Jellyfin recommendations listing every backdrop. In internal/api/handlers, two DB tests outside this change (TestAdminSubtitleListPageDB, TestCatalogTransferPersistsJobsAndSignedLink) fail the same way on fix(metadata): find local artwork the way Kodi and Jellyfin name it, and keep it #2300's branch.
  • Unit tests cover every new name and its precedence, numbered backdrops with gaps, extrafanart/, the cap, the ignored backdrops/ folder, and flat folders. They also cover selection and retention, an unmounted share, locked artwork, a locked provider backdrop, cache keys and write-back, the sweep surfaces, the v2 detail and capability shape, jellycompat tags and routes, and v1 staying unchanged.
  • Live, on a dev sandbox with the TMDB and TVDB plugins: a Kodi-style fixture library of four movies and one series, running fix(metadata): find local artwork the way Kodi and Jellyfin name it, and keep it #2300's head and then this branch with a full refresh on each. Every name in scope was found, and every new cache job succeeded. A second refresh changed nothing. Jellyfin Web 12.1, connected to the sandbox's compatibility port, shows the banners, landscape thumbs and disc art in its Banner, Thumb and Disc views, which were placeholders before. Removing a banner, an extrafanart image, or the whole extrafanart folder dropped them on the next refresh, and restoring them brought them back. /Items/Latest lists the same image tags as the other list paths. That check found a bug: queue preparation restored the removed banner's cached copy. It is fixed here and covered by a test.
  • Reviews: /simplify, /code-review (high) and a Codex adversarial review (gpt-6.1-sol, high) ran in five rounds, on 2645507, ef84e6d, 25d6d78, dfe0926 and 8568a2b. /code-review found 10, 7, 9, 8 and 7 issues and Codex 1, 1, 1, 1 and 0. On the pushes, the Codex connector raised 7 findings and Silo Kody 13; CodeRabbit reported nothing actionable. Everything is fixed except the dismissals below, the known limitation, and the request to file the Apple and Android follow-ups (see Follow-ups). The branch was rebased onto main after fix(metadata): find local artwork the way Kodi and Jellyfin name it, and keep it #2300 and fix(jellycompat): honor every repeated enableImageTypes value #2324 merged, with every commit unchanged (git range-diff); the latest fixes are in f72033c.
Review findings dismissed
  • The provider-ID merge does not move the source item's new slots or extra backdrops. It does not move the poster, backdrop or logo either; the canonical item finds the sidecars again on its next refresh.
  • The Down migration drops the table and columns without queueing their cached files for GC. After a rollback no sweep surface references those files, so the weekly artwork sweep deletes them.
  • The existingImage* helpers rebuild the seven-slot list per lookup. That is a few dozen pointers per item write, next to several database writes.
  • Generalizing the removed-folder rule from extrafanart to every sidecar folder would also drop a moved item's old local art, which fix(metadata): find local artwork the way Kodi and Jellyfin name it, and keep it #2300 deliberately keeps until the new folder supplies some.
  • The provider-artwork backfill walks the four new slots as four surfaces, each a bounded page of media_items keys, rather than one surface emitting four rows per item. That keeps the backfill's one-column-per-surface page bound; it runs only when an admin starts it.
  • The two new migrations were edited in place (index predicates). They have not been released; a database that applied the earlier text keeps IS NOT NULL indexes, which the reference check still uses.
  • Routing /Movies/Recommendations through presignCompatListItems instead of only loading extra backdrops: that helper drops an image whose path it cannot resolve, which recommendations have never done, so the change would go beyond this fix.
  • An extrafanart folder that exists but is empty, or is missing while the item folder answers, counts as removed, for the primary backdrop too. Round 2 settled this for extra backdrops (an emptied folder must drop them); a symlinked folder whose target is down is kept.
  • A nil ImageTags map in applyExtraImageTags cannot happen: itemFromList creates the map.
  • Retiring a displaced backdrop path when Replace or the cache job rewrites a row: the table's AFTER UPDATE OF path and AFTER DELETE triggers already queue it in the same transaction, as for the media_items artwork columns.
  • Under the Images lock, a banner, thumb, clear art or disc slot whose source is still waiting for its cache job holds the slot, as a cached copy does. A changed sidecar is picked up after unlocking, and a job that keeps failing leaves the slot empty with or without the lock.
  • A refresh that lists the backdrop rows just before a cache job writes one can queue that job once more. The cost is one extra cache of an image already cached.
  • Known limitation: a backdrop that sits directly in an item folder which is itself a mount point named extrafanart is dropped if that mount comes back empty while its parent answers. An emptied extrafanart folder looks the same, and it must drop its backdrops. Closing this needs the item's library roots in localArtworkRetention, which fix(metadata): find local artwork the way Kodi and Jellyfin name it, and keep it #2300's retention does not carry.

Evidence: https://evidence.siloserver.org/r/silo-server/local-image-types/

Risks

  • Two additive migrations. The first adds ten columns with constant defaults and a new table, recreates the media_items GC triggers, and widens the cache-job constraints, added NOT VALID so its transaction does not scan the job queue while it holds media_items. The second validates those constraints without blocking writers and builds four partial indexes CONCURRENTLY, like 20260914145000, but on non-empty paths, since most items have none of these images. The artwork reference check (artworkReferenceUnionSQL, shared by the revision GC and the storage sweep) now also skips empty paths on every surface, so a generic plan can use those indexes; the older IS NOT NULL indexes are still used.
  • On upgrade, the first refresh of an item with these sidecars queues one cache job per image, up to 23 per item.
  • A plugin that starts sending banner, thumb, clearart or disc images goes through the same selection as the logo: a local sidecar wins, and rated remote art can replace stored remote art.
  • Merge order with feat(metadata): offer local sidecar artwork in the admin image picker #1981 (picker) and fix(metadata): keep manual metadata edits through refresh and show them in home rails #2254 (manual edits): no shared lines. fix(metadata): keep manual metadata edits through refresh and show them in home rails #2254's artwork-after-Identify rule will apply to the new slots through applyBestImages.

Follow-ups

  • Season banners, thumbs and backdrops (seasonNN-fanart, seasonNN-banner, seasonNN-landscape and the season-folder forms).
  • NFO <thumb aspect="banner|landscape|clearart|discart"> and <fanart> art. A provider returns ImageBanner, ImageThumb, ImageClearArt or ImageDisc images and applyBestImages fills the slot.
  • Several remote backdrops (TMDB returns them already) and banner, clear art and disc kinds from TVDB. These need a product decision on remote backdrops and plugin changes.
  • /api/v2 cards and lists for the new artwork.
  • Apple and Android parity (banner and thumb rows, backdrop rotation): drafted, not filed.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code with code-search and review subagents, GitHub CLI, a Silo dev sandbox's admin API, headless Chromium captures of Jellyfin Web
  • Model(s): claude-opus-5-5 (implementation and review), gpt-6.1-sol (adversarial review)
  • Involvement: Fully AI-generated at the maintainer's direction. The agent verified it on a dev sandbox; no human has verified it yet.
  • Adversarial review: /code-review (high) and a Codex adversarial review (gpt-6.1-sol, high reasoning, read-only, one COMMENT review per round) each ran five times, on 2645507, ef84e6d, 25d6d78, dfe0926 and 8568a2b. Confirmed findings are fixed; dismissals are listed under Validation.

🤖 Generated with Claude Code

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish stacked Base is another open PR; merge in stack order named in the body

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant