From 1f430baa1d51173b70f9242858986c50aabdcc3e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 10 May 2015 17:56:13 -0400 Subject: update dlna profiles --- .../Photos/PhotoAlbumImageProvider.cs | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs index b5ecc94a2..9d2eb297f 100644 --- a/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs @@ -8,37 +8,37 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Photos { - //public class PhotoAlbumImageProvider : IDynamicImageProvider - //{ - // public IEnumerable GetSupportedImages(IHasImages item) - // { - // return new List { ImageType.Primary }; - // } + public class PhotoAlbumImageProvider : IDynamicImageProvider + { + public IEnumerable GetSupportedImages(IHasImages item) + { + return new List { ImageType.Primary }; + } - // public Task GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken) - // { - // var album = (PhotoAlbum)item; + public Task GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken) + { + var album = (PhotoAlbum)item; - // var image = album.Children - // .OfType() - // .Select(i => i.GetImagePath(type)) - // .FirstOrDefault(i => !string.IsNullOrEmpty(i)); + var image = album.Children + .OfType() + .Select(i => i.GetImagePath(type)) + .FirstOrDefault(i => !string.IsNullOrEmpty(i)); - // return Task.FromResult(new DynamicImageResponse - // { - // Path = image, - // HasImage = !string.IsNullOrEmpty(image) - // }); - // } + return Task.FromResult(new DynamicImageResponse + { + Path = image, + HasImage = !string.IsNullOrEmpty(image) + }); + } - // public string Name - // { - // get { return "Image Extractor"; } - // } + public string Name + { + get { return "Image Extractor"; } + } - // public bool Supports(IHasImages item) - // { - // return item is PhotoAlbum; - // } - //} + public bool Supports(IHasImages item) + { + return item is PhotoAlbum; + } + } } -- cgit v1.2.3 From 5492e34c6d1db3c083dacef546da4a3895186ac2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 11 May 2015 12:32:15 -0400 Subject: update indexedDb --- Emby.Drawing/Emby.Drawing.csproj | 1 + Emby.Drawing/GDI/DynamicImageHelpers.cs | 14 ++--- Emby.Drawing/ImageHelpers.cs | 43 +++++++++++++++ Emby.Drawing/ImageMagick/ImageMagickEncoder.cs | 9 +-- Emby.Drawing/ImageMagick/StripCollageBuilder.cs | 64 +++++++--------------- Emby.Drawing/ImageProcessor.cs | 4 ++ MediaBrowser.Api/ApiEntryPoint.cs | 2 +- .../Configuration/EncodingOptions.cs | 2 +- MediaBrowser.Providers/TV/SeriesMetadataService.cs | 2 +- .../Localization/LocalizationManager.cs | 3 + .../Photos/BaseDynamicImageProvider.cs | 29 +++++----- .../UserViews/DynamicImageProvider.cs | 3 +- 12 files changed, 103 insertions(+), 73 deletions(-) create mode 100644 Emby.Drawing/ImageHelpers.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/Emby.Drawing/Emby.Drawing.csproj b/Emby.Drawing/Emby.Drawing.csproj index b286885a5..8aba4263c 100644 --- a/Emby.Drawing/Emby.Drawing.csproj +++ b/Emby.Drawing/Emby.Drawing.csproj @@ -57,6 +57,7 @@ + diff --git a/Emby.Drawing/GDI/DynamicImageHelpers.cs b/Emby.Drawing/GDI/DynamicImageHelpers.cs index c49007c5f..b4a63b31e 100644 --- a/Emby.Drawing/GDI/DynamicImageHelpers.cs +++ b/Emby.Drawing/GDI/DynamicImageHelpers.cs @@ -1,11 +1,9 @@ -using Emby.Drawing.ImageMagick; -using MediaBrowser.Common.IO; +using MediaBrowser.Common.IO; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.IO; -using System.Linq; namespace Emby.Drawing.GDI { @@ -18,10 +16,10 @@ namespace Emby.Drawing.GDI int height) { const int numStrips = 4; - files = StripCollageBuilder.ProjectPaths(files, numStrips).ToList(); - + files = ImageHelpers.ProjectPaths(files, numStrips); + const int rows = 1; - int cols = numStrips; + int cols = numStrips; int cellWidth = 2 * (width / 3); int cellHeight = height; @@ -76,8 +74,8 @@ namespace Emby.Drawing.GDI int width, int height) { - files = StripCollageBuilder.ProjectPaths(files, 4).ToList(); - + files = ImageHelpers.ProjectPaths(files, 4); + const int rows = 2; const int cols = 2; diff --git a/Emby.Drawing/ImageHelpers.cs b/Emby.Drawing/ImageHelpers.cs new file mode 100644 index 000000000..90bde8b3b --- /dev/null +++ b/Emby.Drawing/ImageHelpers.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Emby.Drawing +{ + internal static class ImageHelpers + { + internal static List ProjectPaths(List paths, int count) + { + if (count <= 0) + { + throw new ArgumentOutOfRangeException("count"); + } + if (paths.Count == 0) + { + throw new ArgumentOutOfRangeException("paths"); + } + + var list = new List(); + + AddToList(list, paths, count); + + return list.Take(count).ToList(); + } + + private static void AddToList(List list, List paths, int count) + { + while (list.Count < count) + { + foreach (var path in paths) + { + list.Add(path); + + if (list.Count >= count) + { + return; + } + } + } + } + } +} diff --git a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs index 380c56059..ff4a8f55b 100644 --- a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs +++ b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs @@ -1,4 +1,5 @@ -using ImageMagickSharp; +using System.Linq; +using ImageMagickSharp; using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Drawing; using MediaBrowser.Model.Drawing; @@ -195,15 +196,15 @@ namespace Emby.Drawing.ImageMagick if (ratio >= 1.4) { - new StripCollageBuilder(_appPaths).BuildThumbCollage(options.InputPaths, options.OutputPath, options.Width, options.Height, options.Text); + new StripCollageBuilder(_appPaths).BuildThumbCollage(options.InputPaths.ToList(), options.OutputPath, options.Width, options.Height, options.Text); } else if (ratio >= .9) { - new StripCollageBuilder(_appPaths).BuildSquareCollage(options.InputPaths, options.OutputPath, options.Width, options.Height, options.Text); + new StripCollageBuilder(_appPaths).BuildSquareCollage(options.InputPaths.ToList(), options.OutputPath, options.Width, options.Height, options.Text); } else { - new StripCollageBuilder(_appPaths).BuildPosterCollage(options.InputPaths, options.OutputPath, options.Width, options.Height, options.Text); + new StripCollageBuilder(_appPaths).BuildPosterCollage(options.InputPaths.ToList(), options.OutputPath, options.Width, options.Height, options.Text); } } diff --git a/Emby.Drawing/ImageMagick/StripCollageBuilder.cs b/Emby.Drawing/ImageMagick/StripCollageBuilder.cs index 7cdd0077d..a50a75ccd 100644 --- a/Emby.Drawing/ImageMagick/StripCollageBuilder.cs +++ b/Emby.Drawing/ImageMagick/StripCollageBuilder.cs @@ -2,7 +2,6 @@ using MediaBrowser.Common.Configuration; using System; using System.Collections.Generic; -using System.Linq; namespace Emby.Drawing.ImageMagick { @@ -15,7 +14,7 @@ namespace Emby.Drawing.ImageMagick _appPaths = appPaths; } - public void BuildPosterCollage(IEnumerable paths, string outputPath, int width, int height, string text) + public void BuildPosterCollage(List paths, string outputPath, int width, int height, string text) { if (!string.IsNullOrWhiteSpace(text)) { @@ -33,7 +32,7 @@ namespace Emby.Drawing.ImageMagick } } - public void BuildSquareCollage(IEnumerable paths, string outputPath, int width, int height, string text) + public void BuildSquareCollage(List paths, string outputPath, int width, int height, string text) { if (!string.IsNullOrWhiteSpace(text)) { @@ -51,7 +50,7 @@ namespace Emby.Drawing.ImageMagick } } - public void BuildThumbCollage(IEnumerable paths, string outputPath, int width, int height, string text) + public void BuildThumbCollage(List paths, string outputPath, int width, int height, string text) { if (!string.IsNullOrWhiteSpace(text)) { @@ -69,31 +68,10 @@ namespace Emby.Drawing.ImageMagick } } - internal static string[] ProjectPaths(IEnumerable paths, int count) + private MagickWand BuildThumbCollageWandWithText(List paths, string text, int width, int height) { - var clone = paths.ToList(); - var list = new List(); - - while (list.Count < count) - { - foreach (var path in clone) - { - list.Add(path); - - if (list.Count >= count) - { - break; - } - } - } - - return list.Take(count).ToArray(); - } - - private MagickWand BuildThumbCollageWandWithText(IEnumerable paths, string text, int width, int height) - { - var inputPaths = ProjectPaths(paths, 8); - using (var wandImages = new MagickWand(inputPaths)) + var inputPaths = ImageHelpers.ProjectPaths(paths, 8); + using (var wandImages = new MagickWand(inputPaths.ToArray())) { var wand = new MagickWand(width, height); wand.OpenImage("gradient:#111111-#111111"); @@ -165,10 +143,10 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildPosterCollageWand(IEnumerable paths, int width, int height) + private MagickWand BuildPosterCollageWand(List paths, int width, int height) { - var inputPaths = ProjectPaths(paths, 4); - using (var wandImages = new MagickWand(inputPaths)) + var inputPaths = ImageHelpers.ProjectPaths(paths, 4); + using (var wandImages = new MagickWand(inputPaths.ToArray())) { var wand = new MagickWand(width, height); wand.OpenImage("gradient:#111111-#111111"); @@ -230,10 +208,10 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildPosterCollageWandWithText(IEnumerable paths, string label, int width, int height) + private MagickWand BuildPosterCollageWandWithText(List paths, string label, int width, int height) { - var inputPaths = ProjectPaths(paths, 4); - using (var wandImages = new MagickWand(inputPaths)) + var inputPaths = ImageHelpers.ProjectPaths(paths, 4); + using (var wandImages = new MagickWand(inputPaths.ToArray())) { var wand = new MagickWand(width, height); wand.OpenImage("gradient:#111111-#111111"); @@ -305,10 +283,10 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildThumbCollageWand(IEnumerable paths, int width, int height) + private MagickWand BuildThumbCollageWand(List paths, int width, int height) { - var inputPaths = ProjectPaths(paths, 8); - using (var wandImages = new MagickWand(inputPaths)) + var inputPaths = ImageHelpers.ProjectPaths(paths, 8); + using (var wandImages = new MagickWand(inputPaths.ToArray())) { var wand = new MagickWand(width, height); wand.OpenImage("gradient:#111111-#111111"); @@ -370,10 +348,10 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildSquareCollageWand(IEnumerable paths, int width, int height) + private MagickWand BuildSquareCollageWand(List paths, int width, int height) { - var inputPaths = ProjectPaths(paths, 4); - using (var wandImages = new MagickWand(inputPaths)) + var inputPaths = ImageHelpers.ProjectPaths(paths, 4); + using (var wandImages = new MagickWand(inputPaths.ToArray())) { var wand = new MagickWand(width, height); wand.OpenImage("gradient:#111111-#111111"); @@ -435,10 +413,10 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildSquareCollageWandWithText(IEnumerable paths, string label, int width, int height) + private MagickWand BuildSquareCollageWandWithText(List paths, string label, int width, int height) { - var inputPaths = ProjectPaths(paths, 4); - using (var wandImages = new MagickWand(inputPaths)) + var inputPaths = ImageHelpers.ProjectPaths(paths, 4); + using (var wandImages = new MagickWand(inputPaths.ToArray())) { var wand = new MagickWand(width, height); wand.OpenImage("gradient:#111111-#111111"); diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 59c2e95c7..2ba4f5aab 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -764,7 +764,11 @@ namespace Emby.Drawing try { + _logger.Debug("Creating image collage and saving to {0}", options.OutputPath); + _imageEncoder.CreateImageCollage(options); + + _logger.Debug("Completed creation of image collage and saved to {0}", options.OutputPath); } finally { diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 55aa778e2..2cd900754 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -346,7 +346,7 @@ namespace MediaBrowser.Api // We can really reduce the timeout for apps that are using the newer api if (!string.IsNullOrWhiteSpace(job.PlaySessionId) && job.Type != TranscodingJobType.Progressive) { - timerDuration = 60000; + timerDuration = 50000; } job.PingTimeout = timerDuration; diff --git a/MediaBrowser.Model/Configuration/EncodingOptions.cs b/MediaBrowser.Model/Configuration/EncodingOptions.cs index afd67eb15..7f1607217 100644 --- a/MediaBrowser.Model/Configuration/EncodingOptions.cs +++ b/MediaBrowser.Model/Configuration/EncodingOptions.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Model.Configuration DownMixAudioBoost = 2; EncodingQuality = EncodingQuality.Auto; EnableThrottling = true; - ThrottleThresholdSeconds = 120; + ThrottleThresholdSeconds = 110; } } } diff --git a/MediaBrowser.Providers/TV/SeriesMetadataService.cs b/MediaBrowser.Providers/TV/SeriesMetadataService.cs index b0cd7382a..eeff03703 100644 --- a/MediaBrowser.Providers/TV/SeriesMetadataService.cs +++ b/MediaBrowser.Providers/TV/SeriesMetadataService.cs @@ -52,7 +52,7 @@ namespace MediaBrowser.Providers.TV target.Status = source.Status; } - if (replaceData || target.AirDays.Count == 0) + if (replaceData || target.AirDays == null || target.AirDays.Count == 0) { target.AirDays = source.AirDays; } diff --git a/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs b/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs index 542d67721..e1dd5c618 100644 --- a/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs +++ b/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs @@ -252,6 +252,9 @@ namespace MediaBrowser.Server.Implementations.Localization throw new ArgumentNullException("rating"); } + // Fairly common for some users to have "Rated R" in their rating field + rating = rating.Replace("Rated ", string.Empty, StringComparison.OrdinalIgnoreCase); + var ratingsDictionary = GetParentalRatingsDictionary(); ParentalRating value; diff --git a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs index bd22a8a70..79ebc67d9 100644 --- a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs @@ -103,7 +103,7 @@ namespace MediaBrowser.Server.Implementations.Photos return parts.GetMD5().ToString("N"); } - protected Task CreateThumbCollage(IHasImages primaryItem, List items, string outputPath, bool drawText) + protected Task CreateThumbCollage(IHasImages primaryItem, List items, string outputPath, bool drawText) { return CreateCollage(primaryItem, items, outputPath, 960, 540, drawText, primaryItem.Name); } @@ -115,22 +115,22 @@ namespace MediaBrowser.Server.Implementations.Photos .Where(i => !string.IsNullOrWhiteSpace(i)); } - protected Task CreatePosterCollage(IHasImages primaryItem, List items, string outputPath) + protected Task CreatePosterCollage(IHasImages primaryItem, List items, string outputPath) { return CreateCollage(primaryItem, items, outputPath, 600, 900, true, primaryItem.Name); } - protected Task CreateSquareCollage(IHasImages primaryItem, List items, string outputPath, bool drawText) + protected Task CreateSquareCollage(IHasImages primaryItem, List items, string outputPath, bool drawText) { return CreateCollage(primaryItem, items, outputPath, 800, 800, drawText, primaryItem.Name); } - protected Task CreateThumbCollage(IHasImages primaryItem, List items, string outputPath, int width, int height, bool drawText, string text) + protected Task CreateThumbCollage(IHasImages primaryItem, List items, string outputPath, int width, int height, bool drawText, string text) { return CreateCollage(primaryItem, items, outputPath, width, height, drawText, text); } - private Task CreateCollage(IHasImages primaryItem, List items, string outputPath, int width, int height, bool drawText, string text) + private Task CreateCollage(IHasImages primaryItem, List items, string outputPath, int width, int height, bool drawText, string text) { Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); @@ -143,7 +143,13 @@ namespace MediaBrowser.Server.Implementations.Photos InputPaths = GetStripCollageImagePaths(primaryItem, items).ToArray() }; - return ImageProcessor.CreateImageCollage(options); + if (options.InputPaths.Length == 0) + { + return Task.FromResult(false); + } + + ImageProcessor.CreateImageCollage(options); + return Task.FromResult(true); } public string Name @@ -166,26 +172,23 @@ namespace MediaBrowser.Server.Implementations.Photos if (imageType == ImageType.Thumb) { - await CreateThumbCollage(item, itemsWithImages, outputPath, drawText).ConfigureAwait(false); - return true; + return await CreateThumbCollage(item, itemsWithImages, outputPath, drawText).ConfigureAwait(false); } if (imageType == ImageType.Primary) { if (item is UserView) { - await CreateSquareCollage(item, itemsWithImages, outputPath, drawText).ConfigureAwait(false); + return await CreateSquareCollage(item, itemsWithImages, outputPath, drawText).ConfigureAwait(false); } else if (item is PhotoAlbum || item is Playlist) { - await CreateSquareCollage(item, itemsWithImages, outputPath, drawText).ConfigureAwait(false); + return await CreateSquareCollage(item, itemsWithImages, outputPath, drawText).ConfigureAwait(false); } else { - await CreatePosterCollage(item, itemsWithImages, outputPath).ConfigureAwait(false); + return await CreatePosterCollage(item, itemsWithImages, outputPath).ConfigureAwait(false); } - - return true; } throw new ArgumentException("Unexpected image type"); diff --git a/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs b/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs index 930762696..b07caa1bd 100644 --- a/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs @@ -224,8 +224,7 @@ namespace MediaBrowser.Server.Implementations.UserViews return false; } - await CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540, false, item.Name).ConfigureAwait(false); - return true; + return await CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540, false, item.Name).ConfigureAwait(false); } return await base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex).ConfigureAwait(false); -- cgit v1.2.3 From ff0610b8ec502a51868bc0693a8ac82220e3a4ca Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 11 May 2015 22:35:48 -0400 Subject: add local endpoint --- MediaBrowser.Controller/Dlna/SsdpMessageEventArgs.cs | 2 +- .../EntryPoints/ExternalPortForwarding.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Controller/Dlna/SsdpMessageEventArgs.cs b/MediaBrowser.Controller/Dlna/SsdpMessageEventArgs.cs index 63f3a67aa..804f34311 100644 --- a/MediaBrowser.Controller/Dlna/SsdpMessageEventArgs.cs +++ b/MediaBrowser.Controller/Dlna/SsdpMessageEventArgs.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Dlna public Dictionary Headers { get; set; } - public IPAddress LocalIp { get; set; } + public IPEndPoint LocalEndPoint { get; set; } public byte[] Message { get; set; } public SsdpMessageEventArgs() diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index b5b63181a..fa5841bb8 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -108,9 +108,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints { var endpoint = e.EndPoint as IPEndPoint; - if (endpoint != null && e.LocalIp != null) + if (endpoint != null && e.LocalEndPoint != null) { - NatUtility.Handle(e.LocalIp, e.Message, endpoint, NatProtocol.Upnp); + NatUtility.Handle(e.LocalEndPoint.Address, e.Message, endpoint, NatProtocol.Upnp); } } -- cgit v1.2.3