Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter for Movie Ids in remote id search #187

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Jellyfin.Plugin.Tvdb/TvdbClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,17 @@ public async Task<IReadOnlyList<SearchByRemoteIdResult>> 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<SearchByRemoteIdResult>(), TimeSpan.FromHours(CacheDurationInHours));
return Array.Empty<SearchByRemoteIdResult>();
}

/// <summary>
Expand Down