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:
1 parent
cee6f7f961
commit
a9ff2d089a
33 files changed
+1722
-483
No files matched your search
@@ -4,6 +4,10 @@ const Season = require("../models/Season");
|
||||
const Entry = require("../models/Entry");
|
||||
const EntryId = require("../models/EntryId");
|
||||
const { fetchSeasonData } = require("../services/tmdbService");
|
||||
const {
|
||||
mapSeasonFields,
|
||||
mapEpisodeFields,
|
||||
} = require("../mappers/entryMapper.js");
|
||||
|
||||
class SeasonController {
|
||||
constructor() {
|
||||
@@ -117,14 +121,22 @@ class SeasonController {
|
||||
return res.status(500).send("Couldn't fetch data from TMDB");
|
||||
}
|
||||
|
||||
await season.update({
|
||||
name: seasonData.name,
|
||||
overview: seasonData.overview,
|
||||
episode_count: seasonData.episodes?.length ?? season.episode_count,
|
||||
air_date: seasonData.air_date,
|
||||
tmdb_rating: seasonData.vote_average,
|
||||
poster_path: seasonData.poster_path,
|
||||
});
|
||||
await season.update(mapSeasonFields(seasonData));
|
||||
|
||||
// Keep the season's episodes in sync too (guest stars, crew, votes…)
|
||||
for (const episode of seasonData.episodes ?? []) {
|
||||
const existingEpisode = await Episode.findOne({
|
||||
where: { tmdb_id: episode.id },
|
||||
});
|
||||
if (existingEpisode) {
|
||||
await existingEpisode.update(mapEpisodeFields(episode));
|
||||
} else {
|
||||
await Episode.create({
|
||||
...mapEpisodeFields(episode),
|
||||
season_id: season.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const refreshedSeason = await Season.findByPk(req.params.id);
|
||||
res.send(refreshedSeason);
|
||||
|
||||
Reference in new issue
Block a user