feat(backend): add TMDB preview endpoint for non-library entries

- Add GET /entries/tmdb/preview/:type/:tmdbId endpoint in entryController.js
- Fetch TMDB data via tmdbService.fetchEntryData() without persisting to DB
- Return normalized preview object with title, poster, genres, rating, season/episode counts
This commit is contained in:
Mohammed Abad committed 2026-04-27 04:03:02 +01:00
1 parent 6aa57cbe71
commit 25b645a16f
13 files changed
+199 -10

No files matched your search

+38 -3
View File
@@ -3,6 +3,8 @@ const fsPromises = require('fs').promises;
const fs = require('fs');
const Media = require("../models/Media");
const People = require("../models/People");
const Credit = require("../models/Credit");
const { logToFile } = require('./logService');
const configService = require('./configService');
@@ -18,9 +20,9 @@ class MaintenanceService {
return MaintenanceService.instance;
}
/**
/**
* Delete orphan media records from database,
* these are media records that exist in the database
* these are media records that exist in the database
* but do not have a file in the `user data folder`.
* @param {boolean} [dry=false] - if true only return the count of the files that are getting deleted, default=`false`
*/
@@ -71,7 +73,7 @@ class MaintenanceService {
return removed;
}
/**
/**
* Delete orphan files from media folder data,
* orphan files are files that exist in the `folder data`
* but do not have an instance in the database
@@ -142,6 +144,39 @@ class MaintenanceService {
return removed;
}
/**
* Delete orphan people from the database.
* Orphan people are those not linked to any entry via credits
* AND not manually pinned.
* @param {boolean} [dry=false] - if true only return the count
*/
async deleteOrphanPeople(dry = false) {
const { Sequelize } = require('sequelize');
// Find all people who have no credits and are not pinned
const allPeople = await People.findAll({
include: [{
model: Credit,
as: 'roles',
required: false,
}],
});
const orphans = allPeople.filter(p => (!p.roles || p.roles.length === 0) && !p.pinned);
if (!dry) {
for (const person of orphans) {
await person.destroy();
}
}
const count = orphans.length;
if (dry) logToFile(`Run a dry orphan people check, found: ${count}`);
else logToFile(`Run orphan people cleanup, deleted: ${count}`);
return { count };
}
}
module.exports = new MaintenanceService();