fix(plex-sync): get correct Plex metadata for Hama movie items (#901)

fixes #898
pull/934/head
Mārtiņš Možeiko 3 years ago committed by GitHub
parent 53b7425f67
commit 03cecb3355
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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) {
const mediaRepository = getRepository(Media);
@ -431,8 +450,8 @@ class JobPlexSync {
// 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
if (result?.tmdbId) {
return await this.processMovieWithId(
plexitem,
return await this.processHamaMovie(
metadata,
undefined,
result.tmdbId
);
@ -440,8 +459,8 @@ class JobPlexSync {
const tmdbMovie = await this.tmdb.getMovieByImdbId({
imdbId: result.imdbId,
});
return await this.processMovieWithId(
plexitem,
return await this.processHamaMovie(
metadata,
tmdbMovie,
tmdbMovie.id
);

Loading…
Cancel
Save