Store full TMDB data, add rate limiting and stale-entry refresh

Backend
- Route all TMDB requests through a rate limiter (20 req/s, 8 concurrent)
  with 429/5xx retries; stop logging the API key
- Fetch external ids, certification, keywords, videos, watch providers and
  alternative titles in the entry details request
- Shared entry mapper used by create, refresh, season refresh and importer
- New columns on entries, ids, ratings, seasons, episodes and people, with
  an idempotent startup migration (adds missing columns, widens types)
- Fix TV IMDb ids, network country/logo, episode tmdb_id on refresh, and
  genre/network removal on refresh
- Add stale-entries maintenance job (count, start, cancel) and live
  recommendations endpoint

Frontend
- Entry page: certification, tagline, creators, in-app trailer, vote count,
  TV/movie details, network logos, external links, keywords, where to
  watch, and recommendations
- Episode page: directors, writers and guest stars
- Settings: TMDB refresh card with live progress
This commit is contained in:
X4Lo committed 2026-11-05 11:39:15 +00:00
1 parent cee6f7f961
commit a9ff2d089a
33 files changed
+1722 -483

No files matched your search

+35 -16
View File
@@ -1,9 +1,9 @@
const EntryRating = require('../models/EntryRating');
const collectionManager = require('../services/collectionManager');
const entryManager = require('../services/entryManager');
const entryService = require('../services/entryService');
const tmdbService = require('../services/tmdbService');
const asyncWrapper = require('../utils/asyncWrapper');
const EntryRating = require("../models/EntryRating");
const collectionManager = require("../services/collectionManager");
const entryManager = require("../services/entryManager");
const entryService = require("../services/entryService");
const tmdbService = require("../services/tmdbService");
const asyncWrapper = require("../utils/asyncWrapper");
const _collectionManager = collectionManager;
const _entryManager = entryManager;
@@ -105,7 +105,7 @@ class EntryController {
const seasons = await _entryService.getEntrySeasons(id);
if (seasons.length == 0) {
return res.status(204).json({ message: 'Provided entry has no seasons' });
return res.status(204).json({ message: "Provided entry has no seasons" });
}
res.status(200).json(seasons);
@@ -126,6 +126,25 @@ class EntryController {
res.status(201).json(entry);
});
// * GET - TMDB RECOMMENDATIONS FOR A LIBRARY ENTRY (live, not stored)
getEntryRecommendations = asyncWrapper(async (req, res) => {
const entry = await _entryService.getEntryById(req.params.id, false);
const tmdbId = entry.entryId?.tmdb_id;
if (!tmdbId)
return res.status(400).json({ message: "Entry has no TMDB id" });
const data = await tmdbService.fetchEntryRecommendations(
tmdbId,
entry.is_tvseries,
req.query.page || 1,
);
if (!data)
return res
.status(500)
.json({ message: "Failed to fetch recommendations" });
res.status(200).json(data);
});
// * PUT - REQUEST COLLECTION REFRECH
fetchEntryCollection = asyncWrapper(async (req, res, next) => {
const { id } = req.params;
@@ -145,7 +164,7 @@ class EntryController {
const { page } = req.query;
const data = await tmdbService.fetchTrending(type, page || 1);
if (!data)
return res.status(500).json({ message: 'Failed to fetch trending data' });
return res.status(500).json({ message: "Failed to fetch trending data" });
res.status(200).json(data);
});
@@ -155,7 +174,7 @@ class EntryController {
const { page } = req.query;
const data = await tmdbService.fetchPopular(type, page || 1);
if (!data)
return res.status(500).json({ message: 'Failed to fetch popular data' });
return res.status(500).json({ message: "Failed to fetch popular data" });
res.status(200).json(data);
});
@@ -163,10 +182,10 @@ class EntryController {
getTmdbSearch = asyncWrapper(async (req, res) => {
const { query, page } = req.query;
if (!query)
return res.status(400).json({ message: 'Query parameter is required' });
return res.status(400).json({ message: "Query parameter is required" });
const data = await tmdbService.searchMulti(query, page || 1);
if (!data)
return res.status(500).json({ message: 'Failed to search TMDB' });
return res.status(500).json({ message: "Failed to search TMDB" });
res.status(200).json(data);
});
@@ -178,7 +197,7 @@ class EntryController {
if (!data)
return res
.status(500)
.json({ message: 'Failed to fetch top rated data' });
.json({ message: "Failed to fetch top rated data" });
res.status(200).json(data);
});
@@ -187,17 +206,17 @@ class EntryController {
const { page } = req.query;
const data = await tmdbService.fetchUpcoming(page || 1);
if (!data)
return res.status(500).json({ message: 'Failed to fetch upcoming data' });
return res.status(500).json({ message: "Failed to fetch upcoming data" });
res.status(200).json(data);
});
// * GET - TMDB PREVIEW (fetch details without saving to library)
getTmdbPreview = asyncWrapper(async (req, res) => {
const { type, tmdbId } = req.params;
const is_tvserie = type === 'tv';
const is_tvserie = type === "tv";
const data = await tmdbService.fetchEntryData(tmdbId, is_tvserie);
if (!data)
return res.status(404).json({ message: 'Entry not found on TMDB' });
return res.status(404).json({ message: "Entry not found on TMDB" });
// Fetch credits in parallel
const creditsData = await tmdbService.fetchEntryCredits(tmdbId, is_tvserie);
@@ -208,7 +227,7 @@ class EntryController {
for (const c of creditsData.cast) {
credits.push({
id: c.credit_id || c.id,
cast_type: 'cast',
cast_type: "cast",
character: is_tvserie
? c.roles?.[0]?.character || c.character || null
: c.character || null,