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
+62
-21
@@ -1,27 +1,54 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../config/database');
|
||||
const { DataTypes } = require("sequelize");
|
||||
const sequelize = require("../config/database");
|
||||
|
||||
const Entry = sequelize.define('entry', {
|
||||
const Entry = sequelize.define("entry", {
|
||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||
|
||||
title: { type: DataTypes.STRING(500) },
|
||||
original_title: { type: DataTypes.STRING(100), field: 'original_title' },
|
||||
release_date: { type: DataTypes.DATE, field: 'release_date' },
|
||||
release_status: { type: DataTypes.STRING(50), field: 'release_status' },
|
||||
original_title: { type: DataTypes.STRING(100), field: "original_title" },
|
||||
release_date: { type: DataTypes.DATE, field: "release_date" },
|
||||
release_status: { type: DataTypes.STRING(50), field: "release_status" },
|
||||
runtime: { type: DataTypes.INTEGER },
|
||||
|
||||
tagline: { type: DataTypes.STRING(200) },
|
||||
storyline: { type: DataTypes.STRING(3000) },
|
||||
country: { type: DataTypes.STRING(30) },
|
||||
|
||||
certification: { type: DataTypes.INTEGER },
|
||||
network_studio: { type: DataTypes.STRING(40), field: 'network_studio' },
|
||||
collection_id: { type: DataTypes.INTEGER, field: 'collection_id' },
|
||||
max_cast: { type: DataTypes.INTEGER, field: 'max_cast', defaultValue: 10 },
|
||||
certification: { type: DataTypes.STRING(20) },
|
||||
network_studio: { type: DataTypes.STRING(100), field: "network_studio" },
|
||||
|
||||
// ? TMDB details
|
||||
adult: { type: DataTypes.BOOLEAN, defaultValue: false },
|
||||
tmdb_popularity: { type: DataTypes.FLOAT, field: "tmdb_popularity" },
|
||||
original_language: { type: DataTypes.STRING(10), field: "original_language" },
|
||||
origin_country: { type: DataTypes.JSON, field: "origin_country" },
|
||||
spoken_languages: { type: DataTypes.JSON, field: "spoken_languages" },
|
||||
production_countries: { type: DataTypes.JSON, field: "production_countries" },
|
||||
production_companies: { type: DataTypes.JSON, field: "production_companies" },
|
||||
homepage: { type: DataTypes.STRING(500) },
|
||||
budget: { type: DataTypes.BIGINT },
|
||||
revenue: { type: DataTypes.BIGINT },
|
||||
keywords: { type: DataTypes.JSON },
|
||||
tmdb_videos: { type: DataTypes.JSON, field: "tmdb_videos" },
|
||||
watch_providers: { type: DataTypes.JSON, field: "watch_providers" },
|
||||
alternative_titles: { type: DataTypes.JSON, field: "alternative_titles" },
|
||||
|
||||
// ? TV-only TMDB details
|
||||
tv_type: { type: DataTypes.STRING(30), field: "tv_type" },
|
||||
created_by: { type: DataTypes.JSON, field: "created_by" },
|
||||
number_of_seasons: { type: DataTypes.INTEGER, field: "number_of_seasons" },
|
||||
number_of_episodes: { type: DataTypes.INTEGER, field: "number_of_episodes" },
|
||||
last_air_date: { type: DataTypes.DATEONLY, field: "last_air_date" },
|
||||
in_production: { type: DataTypes.BOOLEAN, field: "in_production" },
|
||||
next_episode_to_air: { type: DataTypes.JSON, field: "next_episode_to_air" },
|
||||
last_episode_to_air: { type: DataTypes.JSON, field: "last_episode_to_air" },
|
||||
|
||||
collection_id: { type: DataTypes.INTEGER, field: "collection_id" },
|
||||
max_cast: { type: DataTypes.INTEGER, field: "max_cast", defaultValue: 10 },
|
||||
credit_fetched: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false,
|
||||
field: 'credit_fetched',
|
||||
field: "credit_fetched",
|
||||
},
|
||||
|
||||
watchlist: { type: DataTypes.BOOLEAN, defaultValue: false },
|
||||
@@ -30,35 +57,49 @@ const Entry = sequelize.define('entry', {
|
||||
showInCalendar: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: true,
|
||||
field: 'show_in_calendar',
|
||||
field: "show_in_calendar",
|
||||
},
|
||||
autoSync: { type: DataTypes.BOOLEAN, defaultValue: true, field: 'auto_sync' },
|
||||
autoSync: { type: DataTypes.BOOLEAN, defaultValue: true, field: "auto_sync" },
|
||||
|
||||
note: { type: DataTypes.STRING(2000) },
|
||||
|
||||
is_tvseries: { type: DataTypes.BOOLEAN, field: 'is_tvseries' },
|
||||
is_tvseries: { type: DataTypes.BOOLEAN, field: "is_tvseries" },
|
||||
status: { type: DataTypes.STRING(20) },
|
||||
|
||||
poster_path: { type: DataTypes.STRING(200), field: 'poster_path' },
|
||||
banner_path: { type: DataTypes.STRING(200), field: 'banner_path' },
|
||||
poster_path: { type: DataTypes.STRING(200), field: "poster_path" },
|
||||
banner_path: { type: DataTypes.STRING(200), field: "banner_path" },
|
||||
|
||||
date_first_seen: { type: DataTypes.DATEONLY, field: 'date_first_seen' },
|
||||
date_last_seen: { type: DataTypes.DATEONLY, field: 'date_last_seen' },
|
||||
date_first_seen: { type: DataTypes.DATEONLY, field: "date_first_seen" },
|
||||
date_last_seen: { type: DataTypes.DATEONLY, field: "date_last_seen" },
|
||||
|
||||
last_fetch: { type: DataTypes.DATEONLY },
|
||||
last_fetch: { type: DataTypes.DATE },
|
||||
|
||||
entry_sync_status: {
|
||||
type: DataTypes.STRING(50),
|
||||
field: 'entry_sync_status',
|
||||
field: "entry_sync_status",
|
||||
allowNull: true,
|
||||
},
|
||||
director: { type: DataTypes.STRING(200), allowNull: true },
|
||||
watch_status: {
|
||||
type: DataTypes.STRING(20),
|
||||
field: 'watch_status',
|
||||
field: "watch_status",
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
});
|
||||
|
||||
// Large JSON columns only needed on the details page; left out of list queries.
|
||||
Entry.DETAIL_ONLY_ATTRIBUTES = [
|
||||
"keywords",
|
||||
"tmdb_videos",
|
||||
"watch_providers",
|
||||
"alternative_titles",
|
||||
"production_companies",
|
||||
"spoken_languages",
|
||||
"production_countries",
|
||||
"created_by",
|
||||
"next_episode_to_air",
|
||||
"last_episode_to_air",
|
||||
];
|
||||
|
||||
module.exports = Entry;
|
||||
@@ -15,6 +15,10 @@ const EntryId = sequelize.define(
|
||||
tmdb_id: { type: DataTypes.STRING(30) },
|
||||
imdb_id: { type: DataTypes.STRING(30) },
|
||||
tvdb_id: { type: DataTypes.STRING(30) },
|
||||
wikidata_id: { type: DataTypes.STRING(30) },
|
||||
facebook_id: { type: DataTypes.STRING(100) },
|
||||
instagram_id: { type: DataTypes.STRING(100) },
|
||||
twitter_id: { type: DataTypes.STRING(100) },
|
||||
},
|
||||
{
|
||||
timestamps: false,
|
||||
|
||||
@@ -14,6 +14,7 @@ const EntryRating = sequelize.define(
|
||||
},
|
||||
user_rating: { type: DataTypes.FLOAT },
|
||||
tmdb_rating: { type: DataTypes.FLOAT },
|
||||
tmdb_vote_count: { type: DataTypes.INTEGER },
|
||||
imdb_rating: { type: DataTypes.FLOAT },
|
||||
rotten_tomatoes_rating: { type: DataTypes.FLOAT },
|
||||
},
|
||||
|
||||
@@ -25,6 +25,11 @@ const Episode = sequelize.define("episode", {
|
||||
|
||||
user_rating: { type: DataTypes.FLOAT },
|
||||
tmdb_rating: { type: DataTypes.FLOAT },
|
||||
tmdb_vote_count: { type: DataTypes.INTEGER },
|
||||
|
||||
production_code: { type: DataTypes.STRING(50) },
|
||||
crew: { type: DataTypes.JSON },
|
||||
guest_stars: { type: DataTypes.JSON },
|
||||
|
||||
still_path: { type: DataTypes.STRING(200) },
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ const sequelize = require("../config/database");
|
||||
const Network = sequelize.define("network", {
|
||||
id: { type: DataTypes.INTEGER, primaryKey: true },
|
||||
|
||||
name: { type: DataTypes.STRING(30) },
|
||||
name: { type: DataTypes.STRING(100) },
|
||||
originCountry: { type: DataTypes.STRING(100), field: "origin_country" },
|
||||
homepage: { type: DataTypes.STRING(100), field: "homepage" },
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ const People = sequelize.define("peoples", {
|
||||
tmdb_id: { type: DataTypes.STRING(100) },
|
||||
|
||||
name: { type: DataTypes.STRING(100) },
|
||||
original_name: { type: DataTypes.STRING(200) },
|
||||
birthday: { type: DataTypes.DATEONLY },
|
||||
deathday: { type: DataTypes.DATEONLY, allowNull: true },
|
||||
gender: { type: DataTypes.INTEGER },
|
||||
|
||||
@@ -6,6 +6,7 @@ const Season = sequelize.define("season", {
|
||||
|
||||
tmdb_id: { type: DataTypes.STRING(30) },
|
||||
imdb_id: { type: DataTypes.STRING(30) },
|
||||
tvdb_id: { type: DataTypes.STRING(30) },
|
||||
|
||||
entry_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
|
||||
Reference in new issue
Block a user