Skip to content

Commit

Permalink
Chore(filter): add a log if filter is empty (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
xjasonlyu authored Dec 8, 2023
1 parent b2c9a14 commit 87f0304
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Jellyfin.Plugin.MetaTube/Providers/MovieProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,19 @@ public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(MovieInfo in

if (Configuration.EnableMovieProviderFilter)
{
var filter = Configuration.GetMovieProviderFilter();
if (filter.Any()) // Apply only if filter is not empty.
if (Configuration.GetMovieProviderFilter() is { } filter &&
filter.Any()) // Apply only if filter is not empty.
{
// Filter out mismatched results.
searchResults.RemoveAll(m => !filter.Contains(m.Provider, StringComparer.OrdinalIgnoreCase));
// Reorder results by stable sort.
searchResults = searchResults.OrderBy(
m => filter.FindIndex(s => s.Equals(m.Provider, StringComparison.OrdinalIgnoreCase))).ToList();
}
else
{
Logger.Warn("Movie provider filter enabled but never used");
}
}

foreach (var m in searchResults)
Expand Down

0 comments on commit 87f0304

Please sign in to comment.