Add duplicate credits maintenance and fix dedup logic

This commit is contained in:
X4Lo committed 2026-06-18 22:08:46 +01:00
1 parent 5a0328a17f
commit 3c089ee110
6 files changed
+188 -5

No files matched your search

+11 -5
View File
@@ -382,9 +382,13 @@ class EntryManager {
const existingCreditsMap = new Map();
for (const credit of existingCreditsList) {
// unique key: people_id + cast_type (scoped to entry_id already)
// unique key: people_id + cast_type + role (character or job)
const roleKey =
credit.cast_type === "cast"
? credit.character || ""
: credit.job || "";
existingCreditsMap.set(
`${credit.people_id}_${credit.cast_type}`,
`${credit.people_id}_${credit.cast_type}_${roleKey}`,
credit,
);
}
@@ -396,9 +400,6 @@ class EntryManager {
const person = existingPeopleMap[c.id];
if (!person) continue;
const key = `${person.id}_${c.cast_type}`;
const existingCredit = existingCreditsMap.get(key);
// For TV series (aggregate_credits), character/job are nested inside roles[]/jobs[].
// Detect TV format by presence of roles/jobs arrays rather than relying on is_tvseries.
const character =
@@ -421,6 +422,11 @@ class EntryManager {
: c.job || null
: null;
// Role key must match map key: use the resolved character/job (after aggregate handling)
const roleKey = c.cast_type === "cast" ? character || "" : job || "";
const key = `${person.id}_${c.cast_type}_${roleKey}`;
const existingCredit = existingCreditsMap.get(key);
const tmdbCreditId = Array.isArray(c.roles)
? c.roles?.[0]?.credit_id
: Array.isArray(c.jobs)