From c4f68615cd2fc0efe959506e4747439ff6165f87 Mon Sep 17 00:00:00 2001 From: Honkertonken <94032937+Honkertonken@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:20:57 +0530 Subject: [PATCH] Update tmdb.ts --- src/backend/metadata/tmdb.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/backend/metadata/tmdb.ts b/src/backend/metadata/tmdb.ts index b143b312..88412c84 100644 --- a/src/backend/metadata/tmdb.ts +++ b/src/backend/metadata/tmdb.ts @@ -173,12 +173,17 @@ export async function multiSearch( language: "en-US", page: 1, }); - // filter out results that aren't movies or shows - const results = data.results.filter( - (r) => - r.media_type === TMDBContentTypes.MOVIE || - r.media_type === TMDBContentTypes.TV, - ); + const currentDate = new Date(); + // filter out results that aren't movies or shows or are unreleased + const results = data.results.filter((r) => { + if (r.media_type === TMDBContentTypes.MOVIE) { + return new Date(r.release_date) <= currentDate; + } + if (r.media_type === TMDBContentTypes.TV) { + return new Date(r.first_air_date) <= currentDate; + } + return false; + }); return results; }