From 30686837161c170d205db21579afc13f76c07a84 Mon Sep 17 00:00:00 2001 From: LJQ Date: Sun, 27 Oct 2024 21:04:04 +0800 Subject: [PATCH] Filter for Movie Ids in remote id search --- Jellyfin.Plugin.Tvdb/TvdbClientManager.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs b/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs index d2d3369..afd3720 100644 --- a/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs +++ b/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs @@ -147,8 +147,17 @@ public async Task> GetMovieByRemoteIdAsync await LoginAsync().ConfigureAwait(false); var searchResult = await searchClient.GetSearchResultsByRemoteIdAsync(remoteId: remoteId, cancellationToken: cancellationToken) .ConfigureAwait(false); - _memoryCache.Set(key, searchResult.Data, TimeSpan.FromHours(CacheDurationInHours)); - return searchResult.Data; + + // Some movies are part of the a series in tvdb and thus episode results are returned with movie results. Filter out the episodes. + var filteredMovies = searchResult.Data?.Where(x => x.Movie?.Id is not null).ToList(); + if (filteredMovies is not null) + { + _memoryCache.Set(key, filteredMovies, TimeSpan.FromHours(CacheDurationInHours)); + return filteredMovies; + } + + _memoryCache.Set(key, Array.Empty(), TimeSpan.FromHours(CacheDurationInHours)); + return Array.Empty(); } ///