diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 9ad72d73f..59c2e95c7 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -53,11 +53,12 @@ namespace Emby.Drawing private readonly IImageEncoder _imageEncoder; private readonly SemaphoreSlim _imageProcessingSemaphore; - public ImageProcessor(ILogger logger, - IServerApplicationPaths appPaths, - IFileSystem fileSystem, - IJsonSerializer jsonSerializer, - IImageEncoder imageEncoder) + public ImageProcessor(ILogger logger, + IServerApplicationPaths appPaths, + IFileSystem fileSystem, + IJsonSerializer jsonSerializer, + IImageEncoder imageEncoder, + int maxConcurrentImageProcesses) { _logger = logger; _fileSystem = fileSystem; @@ -93,8 +94,8 @@ namespace Emby.Drawing } _cachedImagedSizes = new ConcurrentDictionary(sizeDictionary); - var count = Environment.ProcessorCount; - _imageProcessingSemaphore = new SemaphoreSlim(count, count); + _logger.Info("ImageProcessor started with {0} max concurrent image processes", maxConcurrentImageProcesses); + _imageProcessingSemaphore = new SemaphoreSlim(maxConcurrentImageProcesses, maxConcurrentImageProcesses); } public string[] SupportedInputFormats diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 429832088..fc07f6778 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -100,7 +100,19 @@ namespace MediaBrowser.Controller.Entities.Movies /// System.String. protected override string CreateUserDataKey() { - return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.CreateUserDataKey(); + var key = this.GetProviderId(MetadataProviders.Tmdb); + + if (string.IsNullOrWhiteSpace(key)) + { + key = this.GetProviderId(MetadataProviders.Imdb); + } + + if (string.IsNullOrWhiteSpace(key)) + { + key = base.CreateUserDataKey(); + } + + return key; } protected override async Task RefreshedOwnedItems(MetadataRefreshOptions options, List fileSystemChildren, CancellationToken cancellationToken) diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index e7a5c69ba..4696afeb6 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -61,7 +61,7 @@ namespace MediaBrowser.Controller.Entities.TV /// airdate, dvd or absolute /// public string DisplayOrder { get; set; } - + /// /// Gets or sets the status. /// @@ -113,7 +113,19 @@ namespace MediaBrowser.Controller.Entities.TV /// System.String. protected override string CreateUserDataKey() { - return this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Tvcom) ?? base.CreateUserDataKey(); + var key = this.GetProviderId(MetadataProviders.Tvdb); + + if (string.IsNullOrWhiteSpace(key)) + { + key = this.GetProviderId(MetadataProviders.Imdb); + } + + if (string.IsNullOrWhiteSpace(key)) + { + key = base.CreateUserDataKey(); + } + + return key; } /// @@ -188,7 +200,7 @@ namespace MediaBrowser.Controller.Entities.TV public IEnumerable GetEpisodes(User user) { var config = user.Configuration; - + return GetEpisodes(user, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes); } diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 1a20f7431..050b7aabe 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -439,7 +439,7 @@ namespace MediaBrowser.Server.Startup.Common var innerProgress = new ActionableProgress(); innerProgress.RegisterAction(p => progress.Report((.75 * p) + 15)); - ImageProcessor = new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, GetImageEncoder()); + ImageProcessor = GetImageProcessor(); RegisterSingleInstance(ImageProcessor); TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager); @@ -543,6 +543,18 @@ namespace MediaBrowser.Server.Startup.Common await ((UserManager)UserManager).Initialize().ConfigureAwait(false); } + private IImageProcessor GetImageProcessor() + { + var maxConcurrentImageProcesses = Math.Max(Environment.ProcessorCount, 4); + + if (_startupOptions.ContainsOption("-imagethreads")) + { + int.TryParse(_startupOptions.GetOption("-imagethreads"), NumberStyles.Any, CultureInfo.InvariantCulture, out maxConcurrentImageProcesses); + } + + return new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, GetImageEncoder(), maxConcurrentImageProcesses); + } + private IImageEncoder GetImageEncoder() { if (!_startupOptions.ContainsOption("-enablegdi")) diff --git a/SharedVersion.cs b/SharedVersion.cs index 0175399e7..11940767e 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; //[assembly: AssemblyVersion("3.0.*")] -[assembly: AssemblyVersion("3.0.5597.0")] +[assembly: AssemblyVersion("3.0.5597.1")]