re-add tmdbId

This commit is contained in:
thehairy 2023-05-21 21:00:35 +02:00
parent bb869fd7e3
commit fa36493c50
3 changed files with 11 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import { MWMediaType } from "@/backend/metadata/types";
export const testData: DetailedMeta[] = [ export const testData: DetailedMeta[] = [
{ {
imdbId: "tt10954562", imdbId: "tt10954562",
tmdbId: "572716",
meta: { meta: {
id: "439596", id: "439596",
title: "Hamilton", title: "Hamilton",
@ -14,6 +15,7 @@ export const testData: DetailedMeta[] = [
}, },
{ {
imdbId: "tt11126994", imdbId: "tt11126994",
tmdbId: "94605",
meta: { meta: {
id: "222333", id: "222333",
title: "Arcane", title: "Arcane",

View File

@ -30,6 +30,7 @@ interface JWDetailedMeta extends JWMediaResult {
export interface DetailedMeta { export interface DetailedMeta {
meta: MWMediaMeta; meta: MWMediaMeta;
imdbId?: string; imdbId?: string;
tmdbId?: string;
} }
export async function getMetaFromId( export async function getMetaFromId(
@ -60,6 +61,12 @@ export async function getMetaFromId(
if (!imdbId) if (!imdbId)
imdbId = data.external_ids.find((v) => v.provider === "imdb")?.external_id; imdbId = data.external_ids.find((v) => v.provider === "imdb")?.external_id;
let tmdbId = data.external_ids.find(
(v) => v.provider === "tmdb_latest"
)?.external_id;
if (!tmdbId)
tmdbId = data.external_ids.find((v) => v.provider === "tmdb")?.external_id;
let seasonData: JWSeasonMetaResult | undefined; let seasonData: JWSeasonMetaResult | undefined;
if (data.object_type === "show") { if (data.object_type === "show") {
const seasonToScrape = seasonId ?? data.seasons?.[0].id.toString() ?? ""; const seasonToScrape = seasonId ?? data.seasons?.[0].id.toString() ?? "";
@ -72,5 +79,6 @@ export async function getMetaFromId(
return { return {
meta: formatJWMeta(data, seasonData), meta: formatJWMeta(data, seasonData),
imdbId, imdbId,
tmdbId,
}; };
} }

View File

@ -24,6 +24,7 @@ const testData: VideoData = {
}; };
const testMeta: DetailedMeta = { const testMeta: DetailedMeta = {
imdbId: "", imdbId: "",
tmdbId: "",
meta: { meta: {
id: "hello-world", id: "hello-world",
title: "Big Buck Bunny", title: "Big Buck Bunny",