diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index becf649f4..e8f4d51eb 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -33,7 +33,7 @@ namespace MediaBrowser.Common.Implementations
///
/// The type of the T application paths type.
public abstract class BaseApplicationHost : IApplicationHost
- where TApplicationPathsType : class, IApplicationPaths, new()
+ where TApplicationPathsType : class, IApplicationPaths
{
///
/// Occurs when [has pending restart changed].
@@ -83,7 +83,7 @@ namespace MediaBrowser.Common.Implementations
///
/// The json serializer
///
- public readonly IJsonSerializer JsonSerializer = new JsonSerializer();
+ public IJsonSerializer JsonSerializer { get; private set; }
///
/// The _XML serializer
@@ -153,7 +153,7 @@ namespace MediaBrowser.Common.Implementations
protected IInstallationManager InstallationManager { get; private set; }
protected IFileSystem FileSystemManager { get; private set; }
-
+
///
/// Gets or sets the zip client.
///
@@ -181,6 +181,8 @@ namespace MediaBrowser.Common.Implementations
/// Task.
public virtual async Task Init()
{
+ JsonSerializer = CreateJsonSerializer();
+
IsFirstRun = !ConfigurationManager.CommonConfiguration.IsStartupWizardCompleted;
Logger = LogManager.GetLogger("App");
@@ -212,6 +214,11 @@ namespace MediaBrowser.Common.Implementations
}
+ protected virtual IJsonSerializer CreateJsonSerializer()
+ {
+ return new JsonSerializer();
+ }
+
private void SetHttpLimit()
{
try
@@ -224,7 +231,7 @@ namespace MediaBrowser.Common.Implementations
Logger.ErrorException("Error setting http limit", ex);
}
}
-
+
///
/// Installs the iso mounters.
///
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs
index bee5e5dc4..ba68d1f5a 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs
@@ -20,21 +20,23 @@ namespace MediaBrowser.Common.Implementations
///
/// Initializes a new instance of the class.
///
- /// if set to true [use debug paths].
- protected BaseApplicationPaths(bool useDebugPath)
+ protected BaseApplicationPaths(bool useDebugPath, string applicationPath)
{
_useDebugPath = useDebugPath;
+ ApplicationPath = applicationPath;
}
///
/// Initializes a new instance of the class.
///
- /// The program data path.
- protected BaseApplicationPaths(string programDataPath)
+ protected BaseApplicationPaths(string programDataPath, string applicationPath)
{
_programDataPath = programDataPath;
+ ApplicationPath = applicationPath;
}
+ public string ApplicationPath { get; private set; }
+
///
/// The _program data path
///
diff --git a/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs b/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs
index 3ff956040..9c2412b22 100644
--- a/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs
+++ b/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs
@@ -80,7 +80,7 @@ namespace MediaBrowser.Common.Implementations.Serialization
using (Stream stream = File.OpenRead(file))
{
- return ServiceStack.Text.JsonSerializer.DeserializeFromStream(type, stream);
+ return DeserializeFromStream(stream, type);
}
}
@@ -101,7 +101,7 @@ namespace MediaBrowser.Common.Implementations.Serialization
using (Stream stream = File.OpenRead(file))
{
- return ServiceStack.Text.JsonSerializer.DeserializeFromStream(stream);
+ return DeserializeFromStream(stream);
}
}
diff --git a/MediaBrowser.Common/Configuration/IApplicationPaths.cs b/MediaBrowser.Common/Configuration/IApplicationPaths.cs
index d2446ce46..d3bf03302 100644
--- a/MediaBrowser.Common/Configuration/IApplicationPaths.cs
+++ b/MediaBrowser.Common/Configuration/IApplicationPaths.cs
@@ -6,6 +6,12 @@ namespace MediaBrowser.Common.Configuration
///
public interface IApplicationPaths
{
+ ///
+ /// Gets the application path.
+ ///
+ /// The application path.
+ string ApplicationPath { get; }
+
///
/// Gets the path to the program data folder
///
diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs
index 0d9e5ec6d..78e0b8bc4 100644
--- a/MediaBrowser.Controller/Entities/TV/Season.cs
+++ b/MediaBrowser.Controller/Entities/TV/Season.cs
@@ -94,6 +94,22 @@ namespace MediaBrowser.Controller.Entities.TV
get { return _series ?? (_series = FindParent()); }
}
+ [IgnoreDataMember]
+ public string SeriesPath
+ {
+ get
+ {
+ var series = Series;
+
+ if (series != null)
+ {
+ return series.Path;
+ }
+
+ return System.IO.Path.GetDirectoryName(Path);
+ }
+ }
+
///
/// Our rating comes from our series
///
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;
+ }
+ }
+
///
/// Gets the optimized result.
///
@@ -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;
+ }
+
///
/// Gets the specified request.
///
@@ -27,7 +34,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// System.Object.
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 images, string zeroIndexFilename, string numberedIndexPrefix, int index)
+ private string GetBackdropSaveFilename(IEnumerable images, string zeroIndexFilename, string numberedIndexPrefix, int index)
{
if (index == 0)
{
@@ -431,6 +448,8 @@ namespace MediaBrowser.Server.Implementations.Providers
/// imageIndex
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
///
/// Initializes a new instance of the class.
///
- public ServerApplicationPaths()
- : base(true)
+ public ServerApplicationPaths(string applicationPath)
+ : base(true, applicationPath)
{
}
#else
///
/// Initializes a new instance of the class.
///
- public ServerApplicationPaths()
- : base(false)
+ public ServerApplicationPaths(string applicationPath)
+ : base(false, applicationPath)
{
}
#endif
@@ -30,9 +30,8 @@ namespace MediaBrowser.Server.Implementations
///
/// Initializes a new instance of the class.
///
- /// The program data path.
- public ServerApplicationPaths(string programDataPath)
- : base(programDataPath)
+ public ServerApplicationPaths(string programDataPath, string applicationPath)
+ : base(programDataPath, applicationPath)
{
}
diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs
index 057a2456f..d423017fc 100644
--- a/MediaBrowser.Server.Mono/Program.cs
+++ b/MediaBrowser.Server.Mono/Program.cs
@@ -36,7 +36,9 @@ namespace MediaBrowser.Server.Mono
{
Application.Init ();
- var appPaths = CreateApplicationPaths();
+ var applicationPath = Assembly.GetEntryAssembly ().Location;
+
+ var appPaths = CreateApplicationPaths(applicationPath);
var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
logManager.ReloadLogger(LogSeverity.Info);
@@ -65,9 +67,9 @@ namespace MediaBrowser.Server.Mono
}
}
- private static ServerApplicationPaths CreateApplicationPaths()
+ private static ServerApplicationPaths CreateApplicationPaths(string applicationPath)
{
- return new ServerApplicationPaths();
+ return new ServerApplicationPaths(applicationPath);
}
///
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index d2d700839..f51238152 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -27,6 +27,7 @@ using MediaBrowser.Controller.Session;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.MediaInfo;
+using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.System;
using MediaBrowser.Model.Updates;
using MediaBrowser.Providers;
diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs
index d3eed5c48..349cbbc61 100644
--- a/MediaBrowser.ServerApplication/MainStartup.cs
+++ b/MediaBrowser.ServerApplication/MainStartup.cs
@@ -158,7 +158,9 @@ namespace MediaBrowser.ServerApplication
return new ServerApplicationPaths(programDataPath);
}
- return new ServerApplicationPaths();
+ var applicationPath = Process.GetCurrentProcess().MainModule.FileName;
+
+ return new ServerApplicationPaths(applicationPath);
}
///
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs
index fc89441ae..ee893c613 100644
--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs
+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs
@@ -5,7 +5,6 @@ using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dto;
-using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Logging;
@@ -13,7 +12,6 @@ using MediaBrowser.Model.Tasks;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -151,7 +149,7 @@ namespace MediaBrowser.WebDashboard.Api
return _serverConfigurationManager.Configuration.DashboardSourcePath;
}
- var runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
+ var runningDirectory = Path.GetDirectoryName(_serverConfigurationManager.ApplicationPaths.ApplicationPath);
return Path.Combine(runningDirectory, "dashboard-ui");
}