more identify fixes

pull/702/head
Luke Pulverenti 9 years ago
parent e7b0b455f0
commit 6b1c6ace22

@ -20,6 +20,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Providers.Manager
{
@ -60,6 +61,7 @@ namespace MediaBrowser.Providers.Manager
private IEnumerable<IMetadataSaver> _savers;
private IImageSaver[] _imageSavers;
private readonly IServerApplicationPaths _appPaths;
private readonly IJsonSerializer _json;
private IExternalId[] _externalIds;
@ -73,7 +75,7 @@ namespace MediaBrowser.Providers.Manager
/// <param name="libraryMonitor">The directory watchers.</param>
/// <param name="logManager">The log manager.</param>
/// <param name="fileSystem">The file system.</param>
public ProviderManager(IHttpClient httpClient, IServerConfigurationManager configurationManager, ILibraryMonitor libraryMonitor, ILogManager logManager, IFileSystem fileSystem, IServerApplicationPaths appPaths, Func<ILibraryManager> libraryManagerFactory)
public ProviderManager(IHttpClient httpClient, IServerConfigurationManager configurationManager, ILibraryMonitor libraryMonitor, ILogManager logManager, IFileSystem fileSystem, IServerApplicationPaths appPaths, Func<ILibraryManager> libraryManagerFactory, IJsonSerializer json)
{
_logger = logManager.GetLogger("ProviderManager");
_httpClient = httpClient;
@ -82,6 +84,7 @@ namespace MediaBrowser.Providers.Manager
_fileSystem = fileSystem;
_appPaths = appPaths;
_libraryManagerFactory = libraryManagerFactory;
_json = json;
}
/// <summary>
@ -730,8 +733,6 @@ 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
{
@ -761,7 +762,6 @@ namespace MediaBrowser.Providers.Manager
}
var resultList = new List<RemoteSearchResult>();
var foundProviderIds = new Dictionary<Tuple<string, string>, RemoteSearchResult>();
foreach (var provider in providers)
{
@ -771,31 +771,26 @@ namespace MediaBrowser.Providers.Manager
foreach (var result in results)
{
var bFound = false;
var existingMatch = resultList.FirstOrDefault(i => i.ProviderIds.Any(p => string.Equals(result.GetProviderId(p.Key), p.Value, StringComparison.OrdinalIgnoreCase)));
// This check prevents duplicate search results by comparing provider ids
foreach (var providerId in result.ProviderIds)
if (existingMatch == null)
{
var idTuple = new Tuple<string, string>(providerId.Key.ToLower(), providerId.Value.ToLower());
if (!foundProviderIds.ContainsKey(idTuple))
{
foundProviderIds.Add(idTuple, result);
}
else
resultList.Add(result);
}
else
{
foreach (var providerId in result.ProviderIds)
{
bFound = true;
var existingResult = foundProviderIds[idTuple];
if (string.IsNullOrEmpty(existingResult.ImageUrl) && !string.IsNullOrEmpty(result.ImageUrl))
if (!existingMatch.ProviderIds.ContainsKey(providerId.Key))
{
existingResult.ImageUrl = result.ImageUrl;
existingMatch.ProviderIds.Add(providerId.Key, providerId.Value);
}
}
}
if (!bFound && resultList.Count < maxResults)
{
resultList.Add(result);
if (string.IsNullOrWhiteSpace(existingMatch.ImageUrl))
{
existingMatch.ImageUrl = result.ImageUrl;
}
}
}
}
@ -805,6 +800,8 @@ namespace MediaBrowser.Providers.Manager
}
}
//_logger.Debug("Returning search results {0}", _json.SerializeToString(resultList));
return resultList;
}

@ -64,8 +64,6 @@ namespace MediaBrowser.Providers.Omdb
{
var episodeSearchInfo = searchInfo as EpisodeInfo;
var list = new List<RemoteSearchResult>();
var imdbId = searchInfo.GetProviderId(MetadataProviders.Imdb);
var url = "https://www.omdbapi.com/?plot=full&r=json";
@ -148,14 +146,13 @@ namespace MediaBrowser.Providers.Omdb
}
}
foreach (var result in resultList)
return resultList.Select(result =>
{
var item = new RemoteSearchResult
{
IndexNumber = searchInfo.IndexNumber,
Name = result.Title,
ParentIndexNumber = searchInfo.ParentIndexNumber,
ProviderIds = searchInfo.ProviderIds,
SearchProviderName = Name
};
@ -185,11 +182,9 @@ namespace MediaBrowser.Providers.Omdb
item.ImageUrl = result.Poster;
}
list.Add(item);
}
return item;
});
}
return list;
}
public Task<MetadataResult<Trailer>> GetMetadata(TrailerInfo info, CancellationToken cancellationToken)

@ -440,7 +440,7 @@ namespace MediaBrowser.Server.Startup.Common
LibraryMonitor = new LibraryMonitor(LogManager, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, this);
RegisterSingleInstance(LibraryMonitor);
ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager, ApplicationPaths, () => LibraryManager);
ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer);
RegisterSingleInstance(ProviderManager);
SeriesOrderManager = new SeriesOrderManager();

Loading…
Cancel
Save