fix(plugins): type-specific trakt external id namespaces
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
59ccc90bc1
commit
9708fb5e70
@@ -29,7 +29,7 @@ function movieHint(m: TMovie): WorkHint {
|
||||
title: m.title,
|
||||
mediaType: "movie",
|
||||
...(m.year ? { year: m.year } : {}),
|
||||
externalIds: ids({ trakt: m.ids.trakt, tmdb_movie: m.ids.tmdb, imdb: m.ids.imdb }),
|
||||
externalIds: ids({ trakt_movie: m.ids.trakt, tmdb_movie: m.ids.tmdb, imdb: m.ids.imdb }),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -38,21 +38,26 @@ function showHint(s: TShow): WorkHint {
|
||||
title: s.title,
|
||||
mediaType: "show",
|
||||
...(s.year ? { year: s.year } : {}),
|
||||
externalIds: ids({ tmdb_show: s.ids.tmdb, tvdb: s.ids.tvdb, imdb: s.ids.imdb, trakt: s.ids.trakt }),
|
||||
externalIds: ids({ trakt_show: s.ids.trakt, tmdb_show: s.ids.tmdb, tvdb_show: s.ids.tvdb, imdb: s.ids.imdb }),
|
||||
};
|
||||
}
|
||||
|
||||
// Season and episode ids are deliberately omitted: their numeric namespaces (tvdb, tmdb, imdb, trakt)
|
||||
// are shared with shows/movies, so they are identified by parent chain + position instead.
|
||||
function seasonHint(show: TShow, n: number): WorkHint {
|
||||
return { title: `Season ${n}`, mediaType: "season", externalIds: {}, parent: showHint(show), position: { season: n } };
|
||||
function seasonHint(show: TShow, n: number, sid?: Ids): WorkHint {
|
||||
return {
|
||||
title: `Season ${n}`,
|
||||
mediaType: "season",
|
||||
externalIds: sid ? ids({ trakt_season: sid.trakt, tmdb_season: sid.tmdb }) : {},
|
||||
parent: showHint(show),
|
||||
position: { season: n },
|
||||
};
|
||||
}
|
||||
|
||||
function episodeHint(show: TShow, e: TEpisode): WorkHint {
|
||||
const eid = e.ids;
|
||||
return {
|
||||
title: e.title || `Episode ${e.number}`,
|
||||
mediaType: "episode",
|
||||
externalIds: {},
|
||||
externalIds: eid ? ids({ trakt_episode: eid.trakt, tvdb_episode: eid.tvdb, tmdb_episode: eid.tmdb, imdb: eid.imdb }) : {},
|
||||
parent: seasonHint(show, e.season),
|
||||
position: { season: e.season, episode: e.number },
|
||||
};
|
||||
@@ -63,7 +68,7 @@ export function hintFor(item: TItem): WorkHint | null {
|
||||
switch (item.type) {
|
||||
case "movie": return item.movie ? movieHint(item.movie) : null;
|
||||
case "show": return item.show ? showHint(item.show) : null;
|
||||
case "season": return item.show && item.season ? seasonHint(item.show, item.season.number) : null;
|
||||
case "season": return item.show && item.season ? seasonHint(item.show, item.season.number, item.season.ids) : null;
|
||||
case "episode": return item.show && item.episode ? episodeHint(item.show, item.episode) : null;
|
||||
default: return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user