diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations')
4 files changed, 59 insertions, 21 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index e6942fae6..5a5a2dd04 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -99,6 +99,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer return result; } + private bool SupportsCompression + { + get + { + return true; + } + } + /// <summary> /// Gets the optimized result. /// </summary> @@ -116,7 +124,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer throw new ArgumentNullException("result"); } - var optimizedResult = requestContext.ToOptimizedResult(result); + var optimizedResult = SupportsCompression ? requestContext.ToOptimizedResult(result) : result; if (responseHeaders != null) { @@ -458,6 +466,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer } } + if (!SupportsCompression) + { + return new HttpResult(content, contentType); + } + var contents = content.Compress(requestContext.CompressionType); return new CompressedResult(contents, requestContext.CompressionType, contentType); diff --git a/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs b/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs index 20728a30c..904b6799b 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs @@ -1,6 +1,6 @@ -using MediaBrowser.Common.Net; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Net; using ServiceStack.ServiceHost; -using System.Diagnostics; using System.IO; namespace MediaBrowser.Server.Implementations.HttpServer @@ -20,6 +20,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer public class SwaggerService : IHasResultFactory, IRestfulService { + private readonly IApplicationPaths _appPaths; + + public SwaggerService(IApplicationPaths appPaths) + { + _appPaths = appPaths; + } + /// <summary> /// Gets the specified request. /// </summary> @@ -27,7 +34,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// <returns>System.Object.</returns> public object Get(GetSwaggerResource request) { - var runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); + var runningDirectory = Path.GetDirectoryName(_appPaths.ApplicationPath); var swaggerDirectory = Path.Combine(runningDirectory, "swagger-ui"); diff --git a/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs b/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs index 85b17888e..e2192535c 100644 --- a/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs +++ b/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs @@ -6,6 +6,7 @@ using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.IO; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; using System.Globalization; @@ -13,7 +14,6 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Logging; namespace MediaBrowser.Server.Implementations.Providers { @@ -89,6 +89,23 @@ namespace MediaBrowser.Server.Implementations.Providers if (locationType == LocationType.Remote || locationType == LocationType.Virtual) { saveLocally = false; + + var season = item as Season; + + // If season is virtual under a physical series, save locally if using compatible convention + if (season != null && _config.Configuration.ImageSavingConvention == ImageSavingConvention.Compatible) + { + var series = season.Series; + + if (series != null) + { + var seriesLocationType = series.LocationType; + if (seriesLocationType == LocationType.FileSystem || seriesLocationType == LocationType.Offline) + { + saveLocally = true; + } + } + } } if (type == ImageType.Backdrop && imageIndex == null) @@ -402,7 +419,7 @@ namespace MediaBrowser.Server.Implementations.Providers return path; } - private string GetBackdropSaveFilename(List<string> images, string zeroIndexFilename, string numberedIndexPrefix, int index) + private string GetBackdropSaveFilename(IEnumerable<string> images, string zeroIndexFilename, string numberedIndexPrefix, int index) { if (index == 0) { @@ -431,6 +448,8 @@ namespace MediaBrowser.Server.Implementations.Providers /// <exception cref="System.ArgumentNullException">imageIndex</exception> private string[] GetCompatibleSavePaths(BaseItem item, ImageType type, int? imageIndex, string mimeType) { + var season = item as Season; + var extension = mimeType.Split('/').Last(); if (string.Equals(extension, "jpeg", StringComparison.OrdinalIgnoreCase)) @@ -449,9 +468,9 @@ namespace MediaBrowser.Server.Implementations.Providers if (imageIndex.Value == 0) { - if (item is Season && item.IndexNumber.HasValue) + if (season != null && item.IndexNumber.HasValue) { - var seriesFolder = Path.GetDirectoryName(item.Path); + var seriesFolder = season.SeriesPath; var seasonMarker = item.IndexNumber.Value == 0 ? "-specials" @@ -481,9 +500,9 @@ namespace MediaBrowser.Server.Implementations.Providers if (type == ImageType.Primary) { - if (item is Season && item.IndexNumber.HasValue) + if (season != null && item.IndexNumber.HasValue) { - var seriesFolder = Path.GetDirectoryName(item.Path); + var seriesFolder = season.SeriesPath; var seasonMarker = item.IndexNumber.Value == 0 ? "-specials" @@ -518,9 +537,9 @@ namespace MediaBrowser.Server.Implementations.Providers if (type == ImageType.Banner) { - if (item is Season && item.IndexNumber.HasValue) + if (season != null && item.IndexNumber.HasValue) { - var seriesFolder = Path.GetDirectoryName(item.Path); + var seriesFolder = season.SeriesPath; var seasonMarker = item.IndexNumber.Value == 0 ? "-specials" @@ -534,9 +553,9 @@ namespace MediaBrowser.Server.Implementations.Providers if (type == ImageType.Thumb) { - if (item is Season && item.IndexNumber.HasValue) + if (season != null && item.IndexNumber.HasValue) { - var seriesFolder = Path.GetDirectoryName(item.Path); + var seriesFolder = season.SeriesPath; var seasonMarker = item.IndexNumber.Value == 0 ? "-specials" diff --git a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs index fb3c5aec8..db538f8dd 100644 --- a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs +++ b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs @@ -13,16 +13,16 @@ namespace MediaBrowser.Server.Implementations /// <summary> /// Initializes a new instance of the <see cref="ServerApplicationPaths" /> class. /// </summary> - public ServerApplicationPaths() - : base(true) + public ServerApplicationPaths(string applicationPath) + : base(true, applicationPath) { } #else /// <summary> /// Initializes a new instance of the <see cref="ServerApplicationPaths"/> class. /// </summary> - public ServerApplicationPaths() - : base(false) + public ServerApplicationPaths(string applicationPath) + : base(false, applicationPath) { } #endif @@ -30,9 +30,8 @@ namespace MediaBrowser.Server.Implementations /// <summary> /// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class. /// </summary> - /// <param name="programDataPath">The program data path.</param> - public ServerApplicationPaths(string programDataPath) - : base(programDataPath) + public ServerApplicationPaths(string programDataPath, string applicationPath) + : base(programDataPath, applicationPath) { } |
