From 68772e7d9b5273766e3a0e13c60ebec07254a924 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 3 Dec 2016 02:58:48 -0500 Subject: [PATCH] update details --- .../ImageMagickEncoder.cs | 12 ++--- Emby.Drawing/ImageProcessor.cs | 9 +++- .../Library/Validators/PeopleValidator.cs | 47 +------------------ MediaBrowser.Api/Images/ImageRequest.cs | 2 + MediaBrowser.Api/Images/ImageService.cs | 1 + .../Drawing/ImageProcessingOptions.cs | 2 + .../Configuration/PeopleMetadataOptions.cs | 19 -------- .../Configuration/ServerConfiguration.cs | 4 -- MediaBrowser.Model/Entities/MediaStream.cs | 14 +++++- MediaBrowser.Model/MediaBrowser.Model.csproj | 1 - 10 files changed, 32 insertions(+), 79 deletions(-) delete mode 100644 MediaBrowser.Model/Configuration/PeopleMetadataOptions.cs diff --git a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs index 242898e332..39088c94b3 100644 --- a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs +++ b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs @@ -148,7 +148,7 @@ namespace Emby.Drawing.ImageMagick { using (var originalImage = new MagickWand(inputPath)) { - ScaleImage(originalImage, width, height); + ScaleImage(originalImage, width, height, options.Blur ?? 0); if (autoOrient) { @@ -170,7 +170,7 @@ namespace Emby.Drawing.ImageMagick { using (var originalImage = new MagickWand(inputPath)) { - ScaleImage(originalImage, width, height); + ScaleImage(originalImage, width, height, options.Blur ?? 0); if (autoOrient) { @@ -221,13 +221,13 @@ namespace Emby.Drawing.ImageMagick } } - private void ScaleImage(MagickWand wand, int width, int height) + private void ScaleImage(MagickWand wand, int width, int height, int blur) { - var highQuality = false; + var useResize = blur > 1; - if (highQuality) + if (useResize) { - wand.CurrentImage.ResizeImage(width, height); + wand.CurrentImage.ResizeImage(width, height, FilterTypes.GaussianFilter, blur); } else { diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 2224d544c8..a15f75c9ae 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -236,7 +236,7 @@ namespace Emby.Drawing var quality = options.Quality; var outputFormat = GetOutputFormat(options.SupportedOutputFormats[0]); - var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, outputFormat, options.AddPlayedIndicator, options.PercentPlayed, options.UnplayedCount, options.BackgroundColor, options.ForegroundLayer); + var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, outputFormat, options.AddPlayedIndicator, options.PercentPlayed, options.UnplayedCount, options.Blur, options.BackgroundColor, options.ForegroundLayer); var imageProcessingLockTaken = false; @@ -469,7 +469,7 @@ namespace Emby.Drawing /// /// Gets the cache file path based on a set of parameters /// - private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageFormat format, bool addPlayedIndicator, double percentPlayed, int? unwatchedCount, string backgroundColor, string foregroundLayer) + private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageFormat format, bool addPlayedIndicator, double percentPlayed, int? unwatchedCount, int? blur, string backgroundColor, string foregroundLayer) { var filename = originalPath; @@ -498,6 +498,11 @@ namespace Emby.Drawing filename += "p=" + unwatchedCount.Value; } + if (blur.HasValue) + { + filename += "blur=" + blur.Value; + } + if (!string.IsNullOrEmpty(backgroundColor)) { filename += "b=" + backgroundColor; diff --git a/Emby.Server.Implementations/Library/Validators/PeopleValidator.cs b/Emby.Server.Implementations/Library/Validators/PeopleValidator.cs index 6cd24058ae..7ebfd71c09 100644 --- a/Emby.Server.Implementations/Library/Validators/PeopleValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/PeopleValidator.cs @@ -47,36 +47,6 @@ namespace Emby.Server.Implementations.Library.Validators _fileSystem = fileSystem; } - private bool DownloadMetadata(PersonInfo i, PeopleMetadataOptions options) - { - if (i.IsType(PersonType.Actor)) - { - return options.DownloadActorMetadata; - } - if (i.IsType(PersonType.Director)) - { - return options.DownloadDirectorMetadata; - } - if (i.IsType(PersonType.Composer)) - { - return options.DownloadComposerMetadata; - } - if (i.IsType(PersonType.Writer)) - { - return options.DownloadWriterMetadata; - } - if (i.IsType(PersonType.Producer)) - { - return options.DownloadProducerMetadata; - } - if (i.IsType(PersonType.GuestStar)) - { - return options.DownloadGuestStarMetadata; - } - - return options.DownloadOtherPeopleMetadata; - } - /// /// Validates the people. /// @@ -89,28 +59,13 @@ namespace Emby.Server.Implementations.Library.Validators innerProgress.RegisterAction(pct => progress.Report(pct * .15)); - var peopleOptions = _config.Configuration.PeopleMetadataOptions; - var people = _libraryManager.GetPeople(new InternalPeopleQuery()); var dict = new Dictionary(StringComparer.OrdinalIgnoreCase); foreach (var person in people) { - var isMetadataEnabled = DownloadMetadata(person, peopleOptions); - - bool currentValue; - if (dict.TryGetValue(person.Name, out currentValue)) - { - if (!currentValue && isMetadataEnabled) - { - dict[person.Name] = true; - } - } - else - { - dict[person.Name] = isMetadataEnabled; - } + dict[person.Name] = true; } var numComplete = 0; diff --git a/MediaBrowser.Api/Images/ImageRequest.cs b/MediaBrowser.Api/Images/ImageRequest.cs index ba9ffcc159..b61c81972c 100644 --- a/MediaBrowser.Api/Images/ImageRequest.cs +++ b/MediaBrowser.Api/Images/ImageRequest.cs @@ -64,6 +64,8 @@ namespace MediaBrowser.Api.Images [ApiMember(Name = "UnplayedCount", Description = "Optional unplayed count overlay to render", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] public int? UnplayedCount { get; set; } + public int? Blur { get; set; } + [ApiMember(Name = "BackgroundColor", Description = "Optional. Apply a background color for transparent images.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string BackgroundColor { get; set; } diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index f3ad462c41..392654aa25 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -624,6 +624,7 @@ namespace MediaBrowser.Api.Images AddPlayedIndicator = request.AddPlayedIndicator, PercentPlayed = request.PercentPlayed ?? 0, UnplayedCount = request.UnplayedCount, + Blur = request.Blur, BackgroundColor = request.BackgroundColor, ForegroundLayer = request.ForegroundLayer, SupportedOutputFormats = supportedFormats diff --git a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs index 3fd8d84dd5..f4b3d94554 100644 --- a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs +++ b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs @@ -35,6 +35,7 @@ namespace MediaBrowser.Controller.Drawing public bool AddPlayedIndicator { get; set; } public int? UnplayedCount { get; set; } + public int? Blur { get; set; } public double PercentPlayed { get; set; } @@ -84,6 +85,7 @@ namespace MediaBrowser.Controller.Drawing !AddPlayedIndicator && PercentPlayed.Equals(0) && !UnplayedCount.HasValue && + !Blur.HasValue && string.IsNullOrEmpty(BackgroundColor) && string.IsNullOrEmpty(ForegroundLayer); } diff --git a/MediaBrowser.Model/Configuration/PeopleMetadataOptions.cs b/MediaBrowser.Model/Configuration/PeopleMetadataOptions.cs deleted file mode 100644 index 8564d5b5b4..0000000000 --- a/MediaBrowser.Model/Configuration/PeopleMetadataOptions.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace MediaBrowser.Model.Configuration -{ - public class PeopleMetadataOptions - { - public bool DownloadActorMetadata { get; set; } - public bool DownloadDirectorMetadata { get; set; } - public bool DownloadProducerMetadata { get; set; } - public bool DownloadWriterMetadata { get; set; } - public bool DownloadComposerMetadata { get; set; } - public bool DownloadOtherPeopleMetadata { get; set; } - public bool DownloadGuestStarMetadata { get; set; } - - public PeopleMetadataOptions() - { - DownloadActorMetadata = true; - DownloadDirectorMetadata = true; - } - } -} \ No newline at end of file diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 64225ae76c..520cc97018 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -181,8 +181,6 @@ namespace MediaBrowser.Model.Configuration public string UICulture { get; set; } - public PeopleMetadataOptions PeopleMetadataOptions { get; set; } - public bool SaveMetadataHidden { get; set; } public NameValuePair[] ContentTypes { get; set; } @@ -260,8 +258,6 @@ namespace MediaBrowser.Model.Configuration UICulture = "en-us"; - PeopleMetadataOptions = new PeopleMetadataOptions(); - MetadataOptions = new[] { new MetadataOptions(1, 1280) {ItemType = "Book"}, diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.cs index abdebba4ed..85f475ca25 100644 --- a/MediaBrowser.Model/Entities/MediaStream.cs +++ b/MediaBrowser.Model/Entities/MediaStream.cs @@ -118,7 +118,9 @@ namespace MediaBrowser.Model.Entities private string AddLanguageIfNeeded(string title) { - if (!string.IsNullOrEmpty(Language) && !string.Equals(Language, "und", StringComparison.OrdinalIgnoreCase) && title.IndexOf(Language, StringComparison.OrdinalIgnoreCase) == -1) + if (!string.IsNullOrEmpty(Language) && + !string.Equals(Language, "und", StringComparison.OrdinalIgnoreCase) && + !IsLanguageInTitle(title, Language)) { title = StringHelper.FirstToUpper(Language) + " " + title; } @@ -126,6 +128,16 @@ namespace MediaBrowser.Model.Entities return title; } + private bool IsLanguageInTitle(string title, string language) + { + if (title.IndexOf(Language, StringComparison.OrdinalIgnoreCase) != -1) + { + return true; + } + + return false; + } + public string NalLengthSize { get; set; } /// diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 64472ca3a2..f36519e27b 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -84,7 +84,6 @@ -