From ca6383900a68580db39dde2bcb3337fefda480e9 Mon Sep 17 00:00:00 2001 From: cloud <62519659+lem6ns@users.noreply.github.com> Date: Thu, 9 Mar 2023 19:22:41 -0700 Subject: [PATCH 1/3] fix(meta): fallback to no "_latest" --- src/backend/metadata/getmeta.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/metadata/getmeta.ts b/src/backend/metadata/getmeta.ts index cb622e3b..2cc8c91b 100644 --- a/src/backend/metadata/getmeta.ts +++ b/src/backend/metadata/getmeta.ts @@ -56,9 +56,13 @@ export async function getMetaFromId( const imdbId = data.external_ids.find( (v) => v.provider === "imdb_latest" + )?.external_id ?? data.external_ids.find( + (v) => v.provider === "imdb" )?.external_id; const tmdbId = data.external_ids.find( (v) => v.provider === "tmdb_latest" + )?.external_id ?? data.external_ids.find( + (v) => v.provider === "tmdb" )?.external_id; if (!imdbId || !tmdbId) throw new Error("not enough info"); From ac28f32ef4236a641e669685d935befd68ef1301 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 10 Mar 2023 20:54:56 +0100 Subject: [PATCH 2/3] fix linting and make code nicer --- src/backend/metadata/getmeta.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/backend/metadata/getmeta.ts b/src/backend/metadata/getmeta.ts index 2cc8c91b..08679cdd 100644 --- a/src/backend/metadata/getmeta.ts +++ b/src/backend/metadata/getmeta.ts @@ -54,16 +54,21 @@ export async function getMetaFromId( throw err; } - const imdbId = data.external_ids.find( + let imdbId = data.external_ids.find( (v) => v.provider === "imdb_latest" - )?.external_id ?? data.external_ids.find( - (v) => v.provider === "imdb" - )?.external_id; - const tmdbId = data.external_ids.find( + )?.external_id + 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 ?? data.external_ids.find( - (v) => v.provider === "tmdb" - )?.external_id; + )?.external_id + if (!tmdbId) + tmdbId = data.external_ids.find( + (v) => v.provider === "tmdb" + )?.external_id; if (!imdbId || !tmdbId) throw new Error("not enough info"); From 30cc5aa78b40b53ea12a1d3835cc113e5cf75960 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 10 Mar 2023 20:59:10 +0100 Subject: [PATCH 3/3] fix more linting --- src/backend/metadata/getmeta.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/backend/metadata/getmeta.ts b/src/backend/metadata/getmeta.ts index 08679cdd..c0c9e92c 100644 --- a/src/backend/metadata/getmeta.ts +++ b/src/backend/metadata/getmeta.ts @@ -56,19 +56,15 @@ export async function getMetaFromId( let imdbId = data.external_ids.find( (v) => v.provider === "imdb_latest" - )?.external_id + )?.external_id; 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 + )?.external_id; if (!tmdbId) - tmdbId = data.external_ids.find( - (v) => v.provider === "tmdb" - )?.external_id; + tmdbId = data.external_ids.find((v) => v.provider === "tmdb")?.external_id; if (!imdbId || !tmdbId) throw new Error("not enough info");