- New notes: History, Artwork - Rewrite TMDB Integration: single detail request, entry mapper, rate limiter, refresh sync, stale-entry refresh, recommendations - Update pages, routing, API reference, models, database migrations, services, components, hooks, API clients, settings, media system, library, Electron (Tauri in progress) and known issues - Rewrite README for the current React/Express stack and setup
3.4 KiB
title, tags
| title | tags | |||
|---|---|---|---|---|
| Media System |
|
Media System
Overview
Showy downloads images from TMDB and stores them locally. Each image gets a UUID filename and a low-res preview. The Models#Media is polymorphic — it can associate with entries, seasons, episodes, collections, or people.
Pipeline
graph LR
TMDB[TMDB Image API] --> DL[mediaDownloaderService]
DL --> |UUID filename| FS[Local Filesystem]
DL --> OPT[mediaOptimizerService]
OPT --> |_preview suffix| FS
DL --> DB[Media.create]
DB --> MySQL[(MySQL)]
Step by Step
- Download —
mediaDownloaderServicefetches image from TMDB, saves with UUID filename - Optimize —
mediaOptimizerServicegenerates a_previewversion usingsharp- JPEG for photos (posters, backdrops, stills, profiles)
- PNG for logos (transparency)
- Record —
mediaServicecreates aMediaDB record with polymorphic association - Serve — Express serves files via
/api/v1/media/:category/:type/:size/:fileName
Storage Structure
{userDataPath}/images/
├── entries/
│ ├── posters/ {uuid}.jpg + {uuid}_preview.jpg
│ ├── backdrops/ {uuid}.jpg + {uuid}_preview.jpg
│ └── logos/ {uuid}.png + {uuid}_preview.png
├── collections/
│ ├── posters/
│ └── backdrops/
├── seasons/
│ └── posters/
├── episodes/
│ └── stills/
└── peoples/
└── profiles/
{userDataPath} defaults to C:\Users\{user}\Documents\Showy Data — configurable in Env.
Media Model Fields
See Models#Media for full schema.
Key fields:
mediaable— entity type:'entry','people','collection','season','episode'mediaableId— polymorphic FKtype— image type:'poster','backdrop','logo','still','profile'path— UUID filename on diskisSelected— the "active" image displayed in UIisCustom— user-uploaded (vs TMDB-downloaded)tmdbPath— TMDBfile_paththe image came from; recorded on every TMDB download so Artwork can mark images already in the library
Serving URLs
API pattern: GET /api/v1/media/:category/:type/:size/:fileName
| Parameter | Values |
|---|---|
category |
entries, collections, seasons, episodes, peoples |
type |
posters, backdrops, logos, stills, profiles |
size |
preview, full |
fileName |
UUID filename with extension |
Example: /api/v1/media/entries/posters/preview/abc123_preview.jpg
User Uploads
Users can upload custom media via:
POST /entries/:id/media(Multer, supports poster/backdrop/logo)POST /people/:id/media(profile pictures)PUT /collections/:id(multipart with poster/backdrop)
Upload config: mutlerStorageLocations.js — UUID filenames, stored in same directory structure.
Frontend URL Resolution
See Media Utilities for how the frontend resolves which image to display:
- Local selected media → 2. TMDB fallback → 3. Default placeholder
Artwork
Entry pages list every TMDB poster, backdrop and logo merged with the media table, and can download any of them into it. See Artwork.
Maintenance
See Settings Page#Cleanup for orphan file/record detection and removal.
- Orphan files = files on disk with no DB record
- Orphan media records = DB records pointing to missing files