From 6632ac5f1b74e770147b7d036d3c37256b1276a5 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Thu, 5 Aug 2021 23:08:26 +0200 Subject: [PATCH] TheMovieDB: Handling year search/get --- Kyoo.TheMovieDb/ProviderTmdb.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Kyoo.TheMovieDb/ProviderTmdb.cs b/Kyoo.TheMovieDb/ProviderTmdb.cs index 5085b3b1..08bc36ea 100644 --- a/Kyoo.TheMovieDb/ProviderTmdb.cs +++ b/Kyoo.TheMovieDb/ProviderTmdb.cs @@ -95,7 +95,8 @@ namespace Kyoo.TheMovieDb { if (!show.TryGetID(Provider.Slug, out int id)) { - Show found = (await _SearchShows(show.Title ?? show.Slug)).FirstOrDefault(); + Show found = (await _SearchShows(show.Title ?? show.Slug, show.StartAir?.Year)) + .FirstOrDefault(x => x.IsMovie == show.IsMovie); if (found?.TryGetID(Provider.Slug, out id) != true) return found; } @@ -228,11 +229,12 @@ namespace Kyoo.TheMovieDb /// Search for a show using it's name as a query. /// /// The query to search for + /// The year in witch the show has aired. /// A list of shows containing metadata from TheMovieDb - private async Task> _SearchShows(string query) + private async Task> _SearchShows(string query, int? year = null) { TMDbClient client = new(_apiKey.Value.ApiKey); - return (await client.SearchMultiAsync(query)) + return (await client.SearchMultiAsync(query, year: year ?? 0)) .Results .Select(x => {