Jump to content

JellyFinPoster/BIBLE: Difference between revisions

From MindAttic Docs
md2wiki: sync from MindAttic.Docs
 
md2wiki: sync from MindAttic.Docs
 
(One intermediate revision by the same user not shown)
Line 39: Line 39:
* <code>jellyfin_poster.py</code> — the whole refresh (about 320 lines); <code>--write-settings-manifest</code> writes the Vault manifest.
* <code>jellyfin_poster.py</code> — the whole refresh (about 320 lines); <code>--write-settings-manifest</code> writes the Vault manifest.
* <code>vault.py</code> — standard-library-only Vault reader: settings, the <code>jellyfin</code> named key, the one-time <code>.env</code> import.
* <code>vault.py</code> — standard-library-only Vault reader: settings, the <code>jellyfin</code> named key, the one-time <code>.env</code> import.
* <code>bootstrap.ps1</code> / <code>Start.bat</code> — one double-click setup: Python, requirements, <code>.env</code>, scheduled task, first run.
* <code>bootstrap.ps1</code> / <code>Start.bat</code> — one double-click setup: Python, requirements, <code>.env</code>, first run.
* <code>scripts/register_scheduled_task.ps1</code> — registers <code>\MindAttic\JellyFinPoster\JellyfinPosterRefresh</code>.
* <code>tests/test_vault_settings.py</code> — tests for <code>vault.py</code>.
* <code>tests/test_vault_settings.py</code> — tests for <code>vault.py</code>.
* <code>tests/test_library_lookup.py</code> — tests for <code>get_library_item_id</code>'s both-match/type-only/name-only pick order.
* <code>fonts/NotoSans.ttf</code> — the label font.
* <code>fonts/NotoSans.ttf</code> — the label font.


=== 4.2 Domain model (the nouns) ===
=== 4.2 Domain model (the nouns) ===


* <strong>Library</strong> — a Jellyfin VirtualFolder, found by CollectionType (<code>movies</code>, <code>tvshows</code>, <code>books</code>, <code>music</code>), with the display name as a fallback.
* <strong>Library</strong> — a Jellyfin VirtualFolder: a both-match on CollectionType (<code>movies</code>, <code>tvshows</code>, <code>books</code>, <code>music</code>) and the configured Name wins outright, else the first CollectionType-only match, else the first Name-only match.
* <strong>MEDIA</strong> — the four library specs: item type, label, collection type, name, whole-library or newest sampling.
* <strong>MEDIA</strong> — the four library specs: item type, label, collection type, name, whole-library or newest sampling.
* <strong>Collage</strong> — the finished JPEG (quality 85) for one library.
* <strong>Collage</strong> — the finished JPEG (quality 85) for one library.
Line 66: Line 66:


* All four libraries refresh; whole-library sampling for Movies/TV (0fa8d09, JFP-T24); type-before-name lookup (b697d58, JFP-T25); nonzero exit on failure and daily/four-library wording (0112f9b, JFP-T26); Vault settings (bce162d, JFP-T19).
* All four libraries refresh; whole-library sampling for Movies/TV (0fa8d09, JFP-T24); type-before-name lookup (b697d58, JFP-T25); nonzero exit on failure and daily/four-library wording (0112f9b, JFP-T26); Vault settings (bce162d, JFP-T19).
* The nightly run is a MindAttic.Scheduler job, <code>JellyFinPoster.Refresh</code>, which replaces the Windows scheduled task (M.SCHD-T7, closed); <code>bootstrap.ps1</code> still registers the old task.
* The nightly run is a MindAttic.Scheduler job, <code>JellyFinPoster.Refresh</code>, which replaces the Windows scheduled task (M.SCHD-T7, closed); <code>bootstrap.ps1</code> no longer registers any task, and <code>scripts/register_scheduled_task.ps1</code> is gone (JFP-T8, closed).


== 7. Active frontier <span id="JFP-7"></span> ==
== 7. Active frontier <span id="JFP-7"></span> ==

Latest revision as of 06:32, 1 December 2026

JellyFinPoster — Project Bible

Single source of truth for what JellyFinPoster IS, is NOT, and the rules that keep it coherent. README says how to build and run it; this says how to think about it. The finish line lives in docs/RELEASE.md.

1. The one sentence

A Python script that builds a poster collage from each Jellyfin library's own artwork (Movies, TV Shows, Books, Music) and uploads it as that library's Primary image, run once a day unattended.

2. The product promise

  • Fresh tiles, no hand work. Every run redraws all four library tiles; every Jellyfin client sees them at once.
  • Jellyfin's own artwork only. Posters come from GET /Items/{id}/Images/Primary; nothing is fetched from TMDB or any outside service.
  • Clean grids. Up to 5 x 2 posters at 500 x 750; duplicates dropped by MD5 of the image bytes, near-blank images rejected, fewer than 3 usable posters leaves the library's current image alone.
  • Unattended. Runs once per invocation and exits nonzero when a lookup, fetch or upload fails, so the scheduler's retries fire.
  • Settings in Vault. Server URL and library names live in MindAttic Vault (JellyFinPoster settings app), the key in the shared jellyfin named key; .env is imported once and stays a fallback.

3. What it is NOT

  • NOT a Jellyfin plugin: it talks to the server over its HTTP API from the outside.
  • NOT a poster designer: one fixed layout (grid, translucent banner, Noto Sans Bold label, rounded corners).
  • NOT a scheduler: it runs once and exits; repeat runs belong to an OS or MindAttic scheduler.
  • NOT a metadata or artwork fetcher for items: it reads item images, it never changes them.

4. Architecture canon

 vault.py: import .env once -> resolve() -> JF_URL, JF_API_KEY, library names
                    |
 jellyfin_poster.py run(): for movies, tvshows, books, music
   get_library_item_id(collection_type, name)   GET /Library/VirtualFolders
   fetch_item_ids(library, type, limit, whole)  GET /Items (random sample or newest)
   fetch_item_poster(id)                        GET /Items/{id}/Images/Primary
   build_collage() -> draw_title_label()        Pillow
   upload_library_image()                       POST /Items/{libraryId}/Images/Primary (JPEG, base64)

4.1 Modules

  • jellyfin_poster.py — the whole refresh (about 320 lines); --write-settings-manifest writes the Vault manifest.
  • vault.py — standard-library-only Vault reader: settings, the jellyfin named key, the one-time .env import.
  • bootstrap.ps1 / Start.bat — one double-click setup: Python, requirements, .env, first run.
  • tests/test_vault_settings.py — tests for vault.py.
  • tests/test_library_lookup.py — tests for get_library_item_id's both-match/type-only/name-only pick order.
  • fonts/NotoSans.ttf — the label font.

4.2 Domain model (the nouns)

  • Library — a Jellyfin VirtualFolder: a both-match on CollectionType (movies, tvshows, books, music) and the configured Name wins outright, else the first CollectionType-only match, else the first Name-only match.
  • MEDIA — the four library specs: item type, label, collection type, name, whole-library or newest sampling.
  • Collage — the finished JPEG (quality 85) for one library.

4.3 Key services (the verbs)

Library lookup, item sampling (Movies/TV: random over the whole library; Books/Music: recently added; 3x headroom), poster validation and de-duplication, collage composition, upload.

5. The Laws

Inherits MindAttic.HouseRules.md by reference.

  • JFP-LAW-1 — Never break a tile. A library with too few usable posters keeps its current image.
  • JFP-LAW-2 — Fail loudly to the scheduler. Any lookup, fetch or upload failure ends the run nonzero.
  • JFP-LAW-3 — Secrets never in the repo. The Jellyfin key comes from Vault (or an untracked .env).
  • JFP-LAW-4 — One source of artwork: the Jellyfin server itself.

6. Verified state

  • All four libraries refresh; whole-library sampling for Movies/TV (0fa8d09, JFP-T24); type-before-name lookup (b697d58, JFP-T25); nonzero exit on failure and daily/four-library wording (0112f9b, JFP-T26); Vault settings (bce162d, JFP-T19).
  • The nightly run is a MindAttic.Scheduler job, JellyFinPoster.Refresh, which replaces the Windows scheduled task (M.SCHD-T7, closed); bootstrap.ps1 no longer registers any task, and scripts/register_scheduled_task.ps1 is gone (JFP-T8, closed).

7. Active frontier

See docs/RELEASE.md for the milestone, its epics and what is out of scope.

8. Quality bar

A change is done when python -m py_compile jellyfin_poster.py vault.py passes, any new logic has a pytest test in tests/, and the README describes it as built.

9. Glossary

  • Primary image — the Jellyfin image slot shown as a library's tile.
  • VirtualFolder — Jellyfin's name for a library.
From JellyFinPoster/docs/BIBLE.md via MindAttic.Docs; synced automatically, so edit the repo, not this page.