Fix credits linking for TV aggregate format in create and refresh

Handle TV aggregate_credits (roles/jobs arrays) in entry creation,
matching the clean logic already in refresh. Also fix director
detection to search jobs[] array for TV series in both paths.
This commit is contained in:
X4Lo committed 2026-06-29 02:10:24 +01:00
1 parent b117b6bb98
commit ea91c6011a
2 files changed
+66 -18

No files matched your search

+6 -4
View File
@@ -513,10 +513,12 @@ class EntryManager {
console.log(`[CREDITS] No changes for entry ${oldEntry.id}`);
}
// Set director from processed credits
const directorCredit = allCredits.find(
(c) => c.cast_type === "crew" && c.job === "Director",
);
// Set director from processed credits (handles both movie & TV aggregate format)
const directorCredit = allCredits.find((c) => {
if (c.cast_type !== "crew") return false;
const jobs = Array.isArray(c.jobs) ? c.jobs.map((j) => j.job) : [c.job];
return jobs.includes("Director");
});
if (directorCredit) {
oldEntry.director = directorCredit.name || null;
await oldEntry.save();