From ac28f32ef4236a641e669685d935befd68ef1301 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 10 Mar 2023 20:54:56 +0100 Subject: [PATCH] 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");