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
@@ -20,6 +20,13 @@ const networkService = require("./networkService.js");
|
||||
const Cast = require("../models/Credit.js");
|
||||
const People = require("../models/People.js");
|
||||
const Credit = require("../models/Credit.js");
|
||||
const {
|
||||
mapEntryFields,
|
||||
mapEntryIds,
|
||||
mapEntryRatings,
|
||||
mapSeasonFields,
|
||||
mapEpisodeFields,
|
||||
} = require("../mappers/entryMapper.js");
|
||||
|
||||
const _mediaManager = mediaManager;
|
||||
const _mediaOptimizerService = mediaOptimizerService;
|
||||
@@ -35,6 +42,7 @@ class EntryService {
|
||||
|
||||
async getAllEntries() {
|
||||
const entries = await Entry.findAll({
|
||||
attributes: { exclude: Entry.DETAIL_ONLY_ATTRIBUTES },
|
||||
include: [
|
||||
{ model: EntryId, as: "entryId" },
|
||||
{ model: EntryRating, as: "entryRating" },
|
||||
@@ -154,40 +162,20 @@ class EntryService {
|
||||
console.log("entryService > createEntry > is_tvseries: ", is_tvseries);
|
||||
|
||||
let movie = Entry.build({
|
||||
title: data.title || data.name,
|
||||
original_title: data.original_title || data.original_name,
|
||||
release_date: data.release_date || data.first_air_date,
|
||||
release_status: data.status,
|
||||
runtime: data.runtime || null,
|
||||
|
||||
tagline: data.tagline || null,
|
||||
storyline: data.overview,
|
||||
country:
|
||||
data.production_countries.length > 0
|
||||
? data.production_countries[0].name
|
||||
: null,
|
||||
|
||||
...mapEntryFields(data),
|
||||
is_tvseries: is_tvseries,
|
||||
watchlist: true,
|
||||
status: data.status,
|
||||
|
||||
genres: data.genre_ids,
|
||||
|
||||
poster_path: data.poster_path,
|
||||
banner_path: data.backdrop_path,
|
||||
|
||||
last_fetch: new Date(),
|
||||
});
|
||||
|
||||
let savedEntry = await movie.save();
|
||||
|
||||
console.log("entryService > createEntry > savedEntry: ", savedEntry);
|
||||
console.log("entryService > createEntry > savedEntry: ", savedEntry.id);
|
||||
|
||||
// ? ids
|
||||
await EntryId.create({
|
||||
entry_id: savedEntry.id,
|
||||
tmdb_id: data.id,
|
||||
imdb_id: data.imdb_id,
|
||||
...mapEntryIds(data),
|
||||
});
|
||||
|
||||
// ? genres
|
||||
@@ -218,7 +206,7 @@ class EntryService {
|
||||
await EntryRating.create({
|
||||
entry_id: savedEntry.id,
|
||||
user_rating: 0,
|
||||
tmdb_rating: data.vote_average,
|
||||
...mapEntryRatings(data),
|
||||
});
|
||||
|
||||
// ! seasons & episodes for tv series
|
||||
@@ -227,21 +215,12 @@ class EntryService {
|
||||
let seasons = [];
|
||||
for (const season of data.seasons) {
|
||||
let seasonData = await fetchSeasonData(data.id, season.season_number);
|
||||
if (!seasonData) continue;
|
||||
|
||||
const savedSeason = await Season.create({
|
||||
tmdb_id: seasonData.id,
|
||||
|
||||
...mapSeasonFields(seasonData),
|
||||
entry_id: savedEntry.id,
|
||||
|
||||
name: seasonData.name,
|
||||
overview: seasonData.overview,
|
||||
season_number: seasonData.season_number,
|
||||
episode_count: seasonData.episodes.length,
|
||||
air_date: seasonData.air_date,
|
||||
|
||||
user_rating: 0,
|
||||
tmdb_rating: seasonData.vote_average,
|
||||
|
||||
poster_path: seasonData.poster_path,
|
||||
banner_path: null,
|
||||
});
|
||||
|
||||
@@ -251,20 +230,8 @@ class EntryService {
|
||||
let episodes = [];
|
||||
for (const episode of seasonData.episodes) {
|
||||
const savedEpisode = await Episode.create({
|
||||
tmdb_id: episode.id,
|
||||
|
||||
...mapEpisodeFields(episode),
|
||||
season_id: savedSeason.id,
|
||||
|
||||
name: episode.name,
|
||||
overview: episode.overview,
|
||||
episode_number: episode.episode_number,
|
||||
episode_type: episode.episode_type,
|
||||
runtime: episode.runtime,
|
||||
air_date: episode.air_date,
|
||||
|
||||
tmdb_rating: episode.vote_average,
|
||||
|
||||
still_path: episode.still_path,
|
||||
});
|
||||
|
||||
episodes.push(savedEpisode);
|
||||
@@ -309,6 +276,7 @@ class EntryService {
|
||||
return {
|
||||
tmdb_id: credit.id,
|
||||
name: credit.name,
|
||||
original_name: credit.original_name || null,
|
||||
gender: credit.gender || null,
|
||||
popularity: credit.popularity,
|
||||
known_for_department: credit.known_for_department || null,
|
||||
|
||||
Reference in new issue
Block a user