92 lines
2.5 KiB
Markdown
92 lines
2.5 KiB
Markdown
---
|
|
title: TMDB Integration
|
|
tags:
|
|
- backend
|
|
- tmdb
|
|
- external-api
|
|
---
|
|
|
|
# TMDB Integration
|
|
|
|
## 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.
|
|
|
|
## Configuration
|
|
|
|
- API base URL: `https://api.themoviedb.org/3`
|
|
- API key stored in `settings.json` → `tmdbApiKey`
|
|
- Managed by `configService`
|
|
|
|
## tmdbService
|
|
|
|
> [!info] File: `backend/services/tmdbService.js`
|
|
|
|
### Entry Data
|
|
|
|
| Method | TMDB Endpoint | Returns |
|
|
|---|---|---|
|
|
| `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 |
|
|
|
|
### Person Data
|
|
|
|
| Method | TMDB Endpoint |
|
|
|---|---|
|
|
| `fetchPersonDetails(tmdbId)` | `/person/{id}` |
|
|
| `fetchPersonCombinedCredits(tmdbId)` | `/person/{id}/combined_credits` |
|
|
|
|
### Browse & Search
|
|
|
|
| Method | TMDB Endpoint |
|
|
|---|---|
|
|
| `fetchTrending(type)` | `/trending/{type}/week` |
|
|
| `fetchPopular(type)` | `/{type}/popular` |
|
|
| `fetchTopRated(type)` | `/{type}/top_rated` |
|
|
| `fetchUpcoming()` | `/movie/upcoming` |
|
|
| `searchMulti(query, page)` | `/search/multi` |
|
|
| `searchPeople(query)` | `/search/person` |
|
|
| `fetchPopularPeople()` | `/person/popular` |
|
|
|
|
## Frontend TMDB Proxy
|
|
|
|
The frontend accesses TMDB data through backend proxy endpoints (see [[API Reference#TMDB Proxy]]):
|
|
|
|
```
|
|
Frontend → /api/v1/entries/tmdb/trending/movie → Backend → TMDB API → Response
|
|
```
|
|
|
|
This keeps the API key server-side.
|
|
|
|
## Image URLs
|
|
|
|
TMDB image base URL: `https://image.tmdb.org/t/p/`
|
|
|
|
Common sizes used:
|
|
|
|
- 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
|