Browse Source

Merge pull request #1205 from softworkz/AggregateRemoteSearch

Remote-Search: Allow result aggregation of multiple providers
Luke 9 năm trước cách đây
mục cha
commit
ec7e90bcb7

+ 11 - 3
MediaBrowser.Providers/Manager/ProviderManager.cs

@@ -727,6 +727,8 @@ namespace MediaBrowser.Providers.Manager
             where TItemType : BaseItem, new()
             where TItemType : BaseItem, new()
             where TLookupType : ItemLookupInfo
             where TLookupType : ItemLookupInfo
         {
         {
+            const int maxResults = 10;
+
             // Give it a dummy path just so that it looks like a file system item
             // Give it a dummy path just so that it looks like a file system item
             var dummy = new TItemType
             var dummy = new TItemType
             {
             {
@@ -755,6 +757,8 @@ namespace MediaBrowser.Providers.Manager
                 searchInfo.SearchInfo.MetadataCountryCode = ConfigurationManager.Configuration.MetadataCountryCode;
                 searchInfo.SearchInfo.MetadataCountryCode = ConfigurationManager.Configuration.MetadataCountryCode;
             }
             }
 
 
+            var resultList = new List<RemoteSearchResult>();
+
             foreach (var provider in providers)
             foreach (var provider in providers)
             {
             {
                 try
                 try
@@ -765,7 +769,12 @@ namespace MediaBrowser.Providers.Manager
 
 
                     if (list.Count > 0)
                     if (list.Count > 0)
                     {
                     {
-                        return list.Take(10);
+                        resultList.AddRange(list.Take(maxResults - resultList.Count));
+                    }
+
+                    if (resultList.Count >= maxResults)
+                    {
+                        return resultList;
                     }
                     }
                 }
                 }
                 catch (Exception ex)
                 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,
         private async Task<IEnumerable<RemoteSearchResult>> GetSearchResults<TLookupType>(IRemoteSearchProvider<TLookupType> provider, TLookupType searchInfo,