mirror of
https://github.com/sct/overseerr.git
synced 2025-09-30 23:43:33 +02:00
fix(plex): find TV series in addition to movies from IMDb IDs (#1830)
This commit is contained in:
@@ -561,13 +561,13 @@ class TheMovieDb extends ExternalAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getMovieByImdbId({
|
public async getMediaByImdbId({
|
||||||
imdbId,
|
imdbId,
|
||||||
language = 'en',
|
language = 'en',
|
||||||
}: {
|
}: {
|
||||||
imdbId: string;
|
imdbId: string;
|
||||||
language?: string;
|
language?: string;
|
||||||
}): Promise<TmdbMovieDetails> {
|
}): Promise<TmdbMovieDetails | TmdbTvDetails> {
|
||||||
try {
|
try {
|
||||||
const extResponse = await this.getByExternalId({
|
const extResponse = await this.getByExternalId({
|
||||||
externalId: imdbId,
|
externalId: imdbId,
|
||||||
@@ -583,12 +583,19 @@ class TheMovieDb extends ExternalAPI {
|
|||||||
return movie;
|
return movie;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(
|
if (extResponse.tv_results[0]) {
|
||||||
'[TMDb] Failed to find a title with the provided IMDB id'
|
const tvshow = await this.getTvShow({
|
||||||
);
|
tvId: extResponse.tv_results[0].id,
|
||||||
|
language,
|
||||||
|
});
|
||||||
|
|
||||||
|
return tvshow;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(`No movie or show returned from API for ID ${imdbId}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`[TMDb] Failed to get movie by external imdb ID: ${e.message}`
|
`[TMDb] Failed to find media using external IMDb ID: ${e.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -371,10 +371,10 @@ class PlexScanner
|
|||||||
|
|
||||||
// If we got an IMDb ID, but no TMDb ID, lookup the TMDb ID with the IMDb ID
|
// If we got an IMDb ID, but no TMDb ID, lookup the TMDb ID with the IMDb ID
|
||||||
if (mediaIds.imdbId && !mediaIds.tmdbId) {
|
if (mediaIds.imdbId && !mediaIds.tmdbId) {
|
||||||
const tmdbMovie = await this.tmdb.getMovieByImdbId({
|
const tmdbMedia = await this.tmdb.getMediaByImdbId({
|
||||||
imdbId: mediaIds.imdbId,
|
imdbId: mediaIds.imdbId,
|
||||||
});
|
});
|
||||||
mediaIds.tmdbId = tmdbMovie.id;
|
mediaIds.tmdbId = tmdbMedia.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache GUIDs
|
// Cache GUIDs
|
||||||
@@ -385,10 +385,10 @@ class PlexScanner
|
|||||||
const imdbMatch = plexitem.guid.match(imdbRegex);
|
const imdbMatch = plexitem.guid.match(imdbRegex);
|
||||||
if (imdbMatch) {
|
if (imdbMatch) {
|
||||||
mediaIds.imdbId = imdbMatch[1];
|
mediaIds.imdbId = imdbMatch[1];
|
||||||
const tmdbMovie = await this.tmdb.getMovieByImdbId({
|
const tmdbMedia = await this.tmdb.getMediaByImdbId({
|
||||||
imdbId: mediaIds.imdbId,
|
imdbId: mediaIds.imdbId,
|
||||||
});
|
});
|
||||||
mediaIds.tmdbId = tmdbMovie.id;
|
mediaIds.tmdbId = tmdbMedia.id;
|
||||||
}
|
}
|
||||||
// Check if the agent is TMDb
|
// Check if the agent is TMDb
|
||||||
} else if (plexitem.guid.match(tmdbRegex)) {
|
} else if (plexitem.guid.match(tmdbRegex)) {
|
||||||
@@ -473,7 +473,7 @@ class PlexScanner
|
|||||||
mediaIds.tmdbId = result.tmdbId;
|
mediaIds.tmdbId = result.tmdbId;
|
||||||
mediaIds.imdbId = result?.imdbId;
|
mediaIds.imdbId = result?.imdbId;
|
||||||
} else if (result?.imdbId) {
|
} else if (result?.imdbId) {
|
||||||
const tmdbMovie = await this.tmdb.getMovieByImdbId({
|
const tmdbMovie = await this.tmdb.getMediaByImdbId({
|
||||||
imdbId: result.imdbId,
|
imdbId: result.imdbId,
|
||||||
});
|
});
|
||||||
mediaIds.tmdbId = tmdbMovie.id;
|
mediaIds.tmdbId = tmdbMovie.id;
|
||||||
@@ -522,7 +522,7 @@ class PlexScanner
|
|||||||
if (special.tmdbId) {
|
if (special.tmdbId) {
|
||||||
await this.processPlexMovieByTmdbId(episode, special.tmdbId);
|
await this.processPlexMovieByTmdbId(episode, special.tmdbId);
|
||||||
} else if (special.imdbId) {
|
} else if (special.imdbId) {
|
||||||
const tmdbMovie = await this.tmdb.getMovieByImdbId({
|
const tmdbMovie = await this.tmdb.getMediaByImdbId({
|
||||||
imdbId: special.imdbId,
|
imdbId: special.imdbId,
|
||||||
});
|
});
|
||||||
await this.processPlexMovieByTmdbId(episode, tmdbMovie.id);
|
await this.processPlexMovieByTmdbId(episode, tmdbMovie.id);
|
||||||
|
Reference in New Issue
Block a user