Update docs vault and README for recent features
- 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
This commit is contained in:
1 parent
06bf902ad3
commit
229ecef902
20 files changed
+479
-162
No files matched your search
@@ -10,33 +10,47 @@ tags:
|
||||
|
||||
## Overview
|
||||
|
||||
Showy uses **TMDB API v3** as its primary source for movie and TV metadata. All TMDB calls are proxied through the backend — the frontend never contacts TMDB directly.
|
||||
Showy uses **TMDB API v3** as its source for movie, TV and people metadata. All TMDB calls go through the backend — the frontend never talks to TMDB directly, so the API key stays server-side.
|
||||
|
||||
## Configuration
|
||||
|
||||
- API base URL: `https://api.themoviedb.org/3`
|
||||
- API key stored in `settings.json` → `tmdbApiKey`
|
||||
- Managed by `configService`
|
||||
- API base URL: `settings.json` → `tmdbApiUrl` (e.g. `https://api.themoviedb.org/3/`)
|
||||
- API key: `settings.json` → `tmdbApiKey`
|
||||
- Read by `configService`
|
||||
|
||||
## Rate Limiting
|
||||
|
||||
> [!info] File: `backend/services/tmdbService.js` → `tmdbGet(path, params)`
|
||||
|
||||
Every TMDB request goes through one queue so bulk jobs (like the [[API Reference#Stale Entries Refresh|stale entries refresh]]) never get the IP blocked:
|
||||
|
||||
- **20 requests per second**, **8 in flight** at once (TMDB allows ~50/s)
|
||||
- **429** → waits for `Retry-After`, then retries; **5xx / network errors** → exponential backoff
|
||||
- Up to 4 attempts per request
|
||||
- Requests are logged as `TMDB GET <path>?<params>` **without** the API key
|
||||
|
||||
Measured: 45 requests went out at 20 / 20 / 5 per second, all succeeded.
|
||||
|
||||
The legacy [[Import System]] keeps its own extra throttle (35 requests per 10 s) on top.
|
||||
|
||||
## tmdbService
|
||||
|
||||
> [!info] File: `backend/services/tmdbService.js`
|
||||
|
||||
### Entry Data
|
||||
|
||||
| Method | TMDB Endpoint | Returns |
|
||||
| Method | TMDB Endpoint | Notes |
|
||||
|---|---|---|
|
||||
| `fetchEntryData(tmdbId, isTV)` | `/movie/{id}` or `/tv/{id}` | Full entry metadata |
|
||||
| `fetchSeasonData(tmdbId, seasonNum)` | `/tv/{id}/season/{num}` | Season with episodes |
|
||||
| `fetchEntryMedia(tmdbId, isTV)` | `/movie/{id}/images` or `/tv/{id}/images` | Posters, backdrops, logos |
|
||||
| `fetchEntryCredits(tmdbId, isTV)` | `/movie/{id}/credits` or `/tv/{id}/credits` | Cast and crew |
|
||||
| `fetchCollectionData(collectionId)` | `/collection/{id}` | Collection with parts |
|
||||
| `fetchEntryData(tmdbId, isTV)` | `/movie/{id}` or `/tv/{id}` | Appends `external_ids`, `release_dates` (movie) / `content_ratings` (TV), `keywords`, `videos`, `watch/providers`, `alternative_titles` in the same request |
|
||||
| `fetchSeasonData(tmdbId, seasonNum)` | `/tv/{id}/season/{num}` | Appends `external_ids`; episodes include `crew` and `guest_stars` |
|
||||
| `fetchEntryMedia(tmdbId, isTV)` | `/{type}/{id}/images` | All languages (no `language` param) |
|
||||
| `fetchEntryCredits(tmdbId, isTV)` | `/movie/{id}/credits` or `/tv/{id}/aggregate_credits` | |
|
||||
| `fetchEntryRecommendations(tmdbId, isTV, page)` | `/{type}/{id}/recommendations` | Live, never stored |
|
||||
| `fetchCollectionData(collectionId)` | `/collection/{id}` | |
|
||||
|
||||
### Person Data
|
||||
|
||||
| Method | TMDB Endpoint |
|
||||
|---|---|
|
||||
| `fetchPersonDetails(tmdbId)` | `/person/{id}` |
|
||||
| `fetchPersonDetails(tmdbId)` | `/person/{id}` (+ `external_ids`) |
|
||||
| `fetchPersonCombinedCredits(tmdbId)` | `/person/{id}/combined_credits` |
|
||||
|
||||
### Browse & Search
|
||||
@@ -51,41 +65,53 @@ Showy uses **TMDB API v3** as its primary source for movie and TV metadata. All
|
||||
| `searchPeople(query)` | `/search/person` |
|
||||
| `fetchPopularPeople()` | `/person/popular` |
|
||||
|
||||
## Frontend TMDB Proxy
|
||||
All methods return `null` on failure (after retries) and log the error.
|
||||
|
||||
The frontend accesses TMDB data through backend proxy endpoints (see [[API Reference#TMDB Proxy]]):
|
||||
## Entry Mapper
|
||||
|
||||
> [!info] File: `backend/mappers/entryMapper.js`
|
||||
|
||||
One place that turns TMDB responses into column values. Used by entry creation (`entryService.createEntry`), the refresh (`entryManager.refrechEntryById`), the season refresh (`seasonController.refreshSeason`), the legacy importer (`models-services/entryService.saveEntry`) and the TMDB preview endpoint.
|
||||
|
||||
| Function | Fills |
|
||||
|---|---|
|
||||
| `mapEntryFields(data)` | Entry columns — title, dates, runtime (TV falls back to `episode_run_time` then the last episode's runtime), certification (US → GB → origin country; theatrical first for movies), network/studio, budget/revenue, languages, countries, companies, homepage, keywords, trimmed videos and watch providers, alternative titles, TV type/creators/season & episode counts/last air date/next & last episode |
|
||||
| `mapEntryIds(data)` | IMDb (from `external_ids` for TV), TVDB, Wikidata, Facebook, Instagram, X |
|
||||
| `mapEntryRatings(data)` | `tmdb_rating`, `tmdb_vote_count` |
|
||||
| `mapSeasonFields(seasonData)` | Season columns incl. `tvdb_id` |
|
||||
| `mapEpisodeFields(episode)` | Episode columns incl. vote count, production code, directors/writers, guest stars |
|
||||
|
||||
See [[Models#Entry]] for every stored field.
|
||||
|
||||
## Refresh
|
||||
|
||||
`PUT /entries/:id/refresh` (and the stale job) re-fetches and updates:
|
||||
|
||||
- Entry, ids and ratings via the mapper
|
||||
- Genres and networks — **synced both ways** (added and removed); network name, country and logo refreshed
|
||||
- Seasons and episodes (matched by TMDB id)
|
||||
- Credits and people
|
||||
|
||||
### Stale Entries Refresh
|
||||
|
||||
`POST /maintenance/stale-entries/refresh?hours=24` refreshes, one at a time, every entry whose `last_fetch` is older than `hours` (or never set), skipping entries with auto sync off. Progress is available from `GET /maintenance/stale-entries`; the UI is the TMDB Refresh card in [[Settings Page#TMDB Refresh]].
|
||||
|
||||
## Frontend TMDB Proxy
|
||||
|
||||
```
|
||||
Frontend → /api/v1/entries/tmdb/trending/movie → Backend → TMDB API → Response
|
||||
```
|
||||
|
||||
This keeps the API key server-side.
|
||||
See [[API Reference#TMDB Proxy]]. The preview endpoint (`/entries/tmdb/preview/:type/:tmdbId`) returns an `entry` object in the same shape as a library entry, so [[Pages#EntryDetailsPage|EntryDetailsPage]] renders titles that aren't in the library.
|
||||
|
||||
## Image URLs
|
||||
|
||||
TMDB image base URL: `https://image.tmdb.org/t/p/`
|
||||
|
||||
Common sizes used:
|
||||
- Posters: `w185`, `w342`, `w500`
|
||||
- Backdrops: `w780`, `w1280`, `original`
|
||||
- Stills: `w300`, `w780`, `original`
|
||||
- Profiles: `w185`, `w300`
|
||||
- Logos / providers: `w92`, `w500`
|
||||
|
||||
- Posters: `w342`, `w500`, `w780`
|
||||
- Backdrops: `w780`, `w1280`
|
||||
- Stills: `w300`, `w1280`
|
||||
- Profiles: `w185`
|
||||
|
||||
See [[Media Utilities]] for frontend URL resolution and [[Media System]] for local image caching.
|
||||
|
||||
## Lazy Refresh Pattern
|
||||
|
||||
Used by [[Services#EntryManager]] and [[Services#PeopleManager]]:
|
||||
|
||||
1. Check `last_fetch` or `fully_fetched` field
|
||||
2. If stale (>24h) or never fetched → call TMDB
|
||||
3. Update local data + set `last_fetch` to today
|
||||
4. TV series with `status = "Ended"` skip refresh
|
||||
|
||||
## Rate Limiting
|
||||
|
||||
The [[Import System]] self-throttles to stay under TMDB limits:
|
||||
|
||||
- Max 35 requests per 10 seconds
|
||||
- 500ms delay between individual requests
|
||||
See [[Media Utilities]] for frontend URL resolution, [[Media System]] for local caching and [[Artwork]] for browsing and adding TMDB images.
|
||||
Reference in new issue
Block a user