diff options
| author | softworkz <softworkz@hotmail.com> | 2015-10-01 02:36:46 +0200 |
|---|---|---|
| committer | softworkz <softworkz@hotmail.com> | 2015-10-01 03:51:50 +0200 |
| commit | 57fd2ed0f8e3ff8c5a27ad20b3432a23981db089 (patch) | |
| tree | 330a08b10a76d7463b5b43562669e9f985274f97 | |
| parent | 9f1a8d1dc376a63a2ea3045948d07fab84679d96 (diff) | |
Remote-Search: Allow result aggregation of multiple providers
Previously, when a remote search (without provider restriction) was
executed, the search used results from the first provider that returned
at least a single result only. Other providers are ignored.
This commit changes the behaviour in a way that all available providers
are queried until a certain number of search results has been collected.
The number is hardcoded to 10 (like it was before), but could be
parametrized in the future.
| -rw-r--r-- | MediaBrowser.Providers/Manager/ProviderManager.cs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index b2a51377c..b95f25289 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -727,6 +727,8 @@ namespace MediaBrowser.Providers.Manager where TItemType : BaseItem, new() where TLookupType : ItemLookupInfo { + const int maxResults = 10; + // Give it a dummy path just so that it looks like a file system item var dummy = new TItemType { @@ -755,6 +757,8 @@ namespace MediaBrowser.Providers.Manager searchInfo.SearchInfo.MetadataCountryCode = ConfigurationManager.Configuration.MetadataCountryCode; } + var resultList = new List<RemoteSearchResult>(); + foreach (var provider in providers) { try @@ -765,7 +769,12 @@ namespace MediaBrowser.Providers.Manager if (list.Count > 0) { - return list.Take(10); + resultList.AddRange(list.Take(maxResults - resultList.Count)); + } + + if (resultList.Count >= maxResults) + { + return resultList; } } catch (Exception ex) @@ -774,8 +783,7 @@ namespace MediaBrowser.Providers.Manager } } - // Nothing found - return new List<RemoteSearchResult>(); + return resultList; } private async Task<IEnumerable<RemoteSearchResult>> GetSearchResults<TLookupType>(IRemoteSearchProvider<TLookupType> provider, TLookupType searchInfo, |
