From bb869fd7e30b1671cdd7fa0726cf9f9dd7ffc48e Mon Sep 17 00:00:00 2001 From: thehairy Date: Sun, 21 May 2023 18:12:45 +0200 Subject: [PATCH] fix: move meta id check to providers --- src/__tests__/providers/testdata.ts | 2 -- src/backend/metadata/getmeta.ts | 12 +----------- src/backend/providers/gdriveplayer.ts | 1 + src/backend/providers/hdwatched.ts | 1 + src/views/developer/VideoTesterView.tsx | 1 - 5 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/__tests__/providers/testdata.ts b/src/__tests__/providers/testdata.ts index 37e63e06..0789c821 100644 --- a/src/__tests__/providers/testdata.ts +++ b/src/__tests__/providers/testdata.ts @@ -4,7 +4,6 @@ import { MWMediaType } from "@/backend/metadata/types"; export const testData: DetailedMeta[] = [ { imdbId: "tt10954562", - tmdbId: "572716", meta: { id: "439596", title: "Hamilton", @@ -15,7 +14,6 @@ export const testData: DetailedMeta[] = [ }, { imdbId: "tt11126994", - tmdbId: "94605", meta: { id: "222333", title: "Arcane", diff --git a/src/backend/metadata/getmeta.ts b/src/backend/metadata/getmeta.ts index 215448e5..6f7c7058 100644 --- a/src/backend/metadata/getmeta.ts +++ b/src/backend/metadata/getmeta.ts @@ -29,8 +29,7 @@ interface JWDetailedMeta extends JWMediaResult { export interface DetailedMeta { meta: MWMediaMeta; - tmdbId: string; - imdbId: string; + imdbId?: string; } export async function getMetaFromId( @@ -61,14 +60,6 @@ export async function getMetaFromId( if (!imdbId) 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; - - if (!imdbId || !tmdbId) throw new Error("not enough info"); - let seasonData: JWSeasonMetaResult | undefined; if (data.object_type === "show") { const seasonToScrape = seasonId ?? data.seasons?.[0].id.toString() ?? ""; @@ -81,6 +72,5 @@ export async function getMetaFromId( return { meta: formatJWMeta(data, seasonData), imdbId, - tmdbId, }; } diff --git a/src/backend/providers/gdriveplayer.ts b/src/backend/providers/gdriveplayer.ts index 2023b67d..5478b6ed 100644 --- a/src/backend/providers/gdriveplayer.ts +++ b/src/backend/providers/gdriveplayer.ts @@ -41,6 +41,7 @@ registerProvider({ type: [MWMediaType.MOVIE], async scrape({ progress, media: { imdbId } }) { + if (!imdbId) throw new Error("not enough info"); progress(10); const streamRes = await proxiedFetch( "https://database.gdriveplayer.us/player.php", diff --git a/src/backend/providers/hdwatched.ts b/src/backend/providers/hdwatched.ts index cacaec41..2096e160 100644 --- a/src/backend/providers/hdwatched.ts +++ b/src/backend/providers/hdwatched.ts @@ -123,6 +123,7 @@ registerProvider({ type: [MWMediaType.MOVIE, MWMediaType.SERIES], async scrape(options) { const { media, progress } = options; + if (!media.imdbId) throw new Error("not enough info"); if (!this.type.includes(media.meta.type)) { throw new Error("Unsupported type"); } diff --git a/src/views/developer/VideoTesterView.tsx b/src/views/developer/VideoTesterView.tsx index b192cd40..66211408 100644 --- a/src/views/developer/VideoTesterView.tsx +++ b/src/views/developer/VideoTesterView.tsx @@ -24,7 +24,6 @@ const testData: VideoData = { }; const testMeta: DetailedMeta = { imdbId: "", - tmdbId: "", meta: { id: "hello-world", title: "Big Buck Bunny",