fix(plex-sync): get correct Plex metadata for Hama movie items (#901)
fixes #898
This commit is contained in:
@@ -353,6 +353,25 @@ class JobPlexSync {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// movies with hama agent actually are tv shows with at least one episode in it
|
||||||
|
// try to get first episode of any season - cannot hardcode season or episode number
|
||||||
|
// because sometimes user can have it in other season/ep than s01e01
|
||||||
|
private async processHamaMovie(
|
||||||
|
metadata: PlexMetadata,
|
||||||
|
tmdbMovie: TmdbMovieDetails | undefined,
|
||||||
|
tmdbMovieId: number
|
||||||
|
) {
|
||||||
|
const season = metadata.Children?.Metadata[0];
|
||||||
|
if (season) {
|
||||||
|
const episodes = await this.plexClient.getChildrenMetadata(
|
||||||
|
season.ratingKey
|
||||||
|
);
|
||||||
|
if (episodes) {
|
||||||
|
await this.processMovieWithId(episodes[0], tmdbMovie, tmdbMovieId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async processShow(plexitem: PlexLibraryItem) {
|
private async processShow(plexitem: PlexLibraryItem) {
|
||||||
const mediaRepository = getRepository(Media);
|
const mediaRepository = getRepository(Media);
|
||||||
|
|
||||||
@@ -431,8 +450,8 @@ class JobPlexSync {
|
|||||||
// if lookup of tvshow above failed, then try movie with tmdbid/imdbid
|
// if lookup of tvshow above failed, then try movie with tmdbid/imdbid
|
||||||
// note - some tv shows have imdbid set too, that's why this need to go second
|
// note - some tv shows have imdbid set too, that's why this need to go second
|
||||||
if (result?.tmdbId) {
|
if (result?.tmdbId) {
|
||||||
return await this.processMovieWithId(
|
return await this.processHamaMovie(
|
||||||
plexitem,
|
metadata,
|
||||||
undefined,
|
undefined,
|
||||||
result.tmdbId
|
result.tmdbId
|
||||||
);
|
);
|
||||||
@@ -440,8 +459,8 @@ class JobPlexSync {
|
|||||||
const tmdbMovie = await this.tmdb.getMovieByImdbId({
|
const tmdbMovie = await this.tmdb.getMovieByImdbId({
|
||||||
imdbId: result.imdbId,
|
imdbId: result.imdbId,
|
||||||
});
|
});
|
||||||
return await this.processMovieWithId(
|
return await this.processHamaMovie(
|
||||||
plexitem,
|
metadata,
|
||||||
tmdbMovie,
|
tmdbMovie,
|
||||||
tmdbMovie.id
|
tmdbMovie.id
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user