mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +01:00
use external ids endpoint for imdb ids
This commit is contained in:
parent
0d249a3e27
commit
205248a376
3 changed files with 51 additions and 4 deletions
|
@ -87,10 +87,8 @@ export async function getMetaFromId(
|
|||
|
||||
if (!details) return null;
|
||||
|
||||
let imdbId;
|
||||
if (type === MWMediaType.MOVIE) {
|
||||
imdbId = (details as TMDBMovieData).imdb_id ?? undefined;
|
||||
}
|
||||
const externalIds = await Tmdb.getExternalIds(id, mediaTypeToTMDB(type));
|
||||
const imdbId = externalIds.imdb_id ?? undefined;
|
||||
|
||||
let seasonData: TMDBSeasonMetaResult | undefined;
|
||||
|
||||
|
|
|
@ -6,15 +6,18 @@ import {
|
|||
MWSeasonMeta,
|
||||
TMDBContentTypes,
|
||||
TMDBEpisodeShort,
|
||||
TMDBExternalIds,
|
||||
TMDBMediaResult,
|
||||
TMDBMediaStatic,
|
||||
TMDBMovieData,
|
||||
TMDBMovieExternalIds,
|
||||
TMDBMovieResponse,
|
||||
TMDBMovieResult,
|
||||
TMDBSearchResultStatic,
|
||||
TMDBSeason,
|
||||
TMDBSeasonMetaResult,
|
||||
TMDBShowData,
|
||||
TMDBShowExternalIds,
|
||||
TMDBShowResponse,
|
||||
TMDBShowResult,
|
||||
} from "./types";
|
||||
|
@ -170,6 +173,28 @@ export abstract class Tmdb {
|
|||
title: e.name,
|
||||
}));
|
||||
}
|
||||
|
||||
public static async getExternalIds(
|
||||
id: string,
|
||||
type: TMDBContentTypes
|
||||
): Promise<TMDBExternalIds> {
|
||||
let data;
|
||||
|
||||
switch (type) {
|
||||
case "movie":
|
||||
data = await Tmdb.get<TMDBMovieExternalIds>(
|
||||
`/movie/${id}/external_ids`
|
||||
);
|
||||
break;
|
||||
case "show":
|
||||
data = await Tmdb.get<TMDBShowExternalIds>(`/tv/${id}/external_ids`);
|
||||
break;
|
||||
default:
|
||||
throw new Error("Invalid media type");
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
export async function formatTMDBSearchResult(
|
||||
|
|
|
@ -379,3 +379,27 @@ export interface TMDBSeason {
|
|||
poster_path: string | null;
|
||||
season_number: number;
|
||||
}
|
||||
|
||||
export interface TMDBShowExternalIds {
|
||||
id: number;
|
||||
imdb_id: null | string;
|
||||
freebase_mid: null | string;
|
||||
freebase_id: null | string;
|
||||
tvdb_id: number;
|
||||
tvrage_id: null | string;
|
||||
wikidata_id: null | string;
|
||||
facebook_id: null | string;
|
||||
instagram_id: null | string;
|
||||
twitter_id: null | string;
|
||||
}
|
||||
|
||||
export interface TMDBMovieExternalIds {
|
||||
id: number;
|
||||
imdb_id: null | string;
|
||||
wikidata_id: null | string;
|
||||
facebook_id: null | string;
|
||||
instagram_id: null | string;
|
||||
twitter_id: null | string;
|
||||
}
|
||||
|
||||
export type TMDBExternalIds = TMDBShowExternalIds | TMDBMovieExternalIds;
|
||||
|
|
Loading…
Reference in a new issue