Don't append transcodes to transcoding temp path
This commit is contained in:
parent
d868a8da6c
commit
d4b438791f
|
@ -4,7 +4,6 @@ using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Events;
|
using MediaBrowser.Common.Events;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
|
@ -16,7 +15,7 @@ using Microsoft.Extensions.Logging;
|
||||||
namespace Emby.Server.Implementations.AppBase
|
namespace Emby.Server.Implementations.AppBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class BaseConfigurationManager
|
/// Class BaseConfigurationManager.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class BaseConfigurationManager : IConfigurationManager
|
public abstract class BaseConfigurationManager : IConfigurationManager
|
||||||
{
|
{
|
||||||
|
@ -314,8 +313,7 @@ namespace Emby.Server.Implementations.AppBase
|
||||||
throw new ArgumentException("Expected configuration type is " + configurationType.Name);
|
throw new ArgumentException("Expected configuration type is " + configurationType.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
var validatingStore = configurationStore as IValidatingConfiguration;
|
if (configurationStore is IValidatingConfiguration validatingStore)
|
||||||
if (validatingStore != null)
|
|
||||||
{
|
{
|
||||||
var currentConfiguration = GetConfiguration(key);
|
var currentConfiguration = GetConfiguration(key);
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,6 @@ using MediaBrowser.Model.Cryptography;
|
||||||
using MediaBrowser.Model.Diagnostics;
|
using MediaBrowser.Model.Diagnostics;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.Events;
|
using MediaBrowser.Model.Events;
|
||||||
using MediaBrowser.Model.Extensions;
|
|
||||||
using MediaBrowser.Model.Globalization;
|
using MediaBrowser.Model.Globalization;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
|
@ -110,7 +109,6 @@ using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http.Extensions;
|
using Microsoft.AspNetCore.Http.Extensions;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
||||||
|
@ -1424,6 +1422,7 @@ namespace Emby.Server.Implementations
|
||||||
public async Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken)
|
public async Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
|
var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
|
||||||
|
var transcodingTempPath = ConfigurationManager.GetTranscodePath();
|
||||||
|
|
||||||
return new SystemInfo
|
return new SystemInfo
|
||||||
{
|
{
|
||||||
|
@ -1447,7 +1446,7 @@ namespace Emby.Server.Implementations
|
||||||
CanSelfRestart = CanSelfRestart,
|
CanSelfRestart = CanSelfRestart,
|
||||||
CanLaunchWebBrowser = CanLaunchWebBrowser,
|
CanLaunchWebBrowser = CanLaunchWebBrowser,
|
||||||
HasUpdateAvailable = HasUpdateAvailable,
|
HasUpdateAvailable = HasUpdateAvailable,
|
||||||
TranscodingTempPath = ApplicationPaths.TranscodePath,
|
TranscodingTempPath = transcodingTempPath,
|
||||||
ServerName = FriendlyName,
|
ServerName = FriendlyName,
|
||||||
LocalAddress = localAddress,
|
LocalAddress = localAddress,
|
||||||
SupportsLibraryMonitor = true,
|
SupportsLibraryMonitor = true,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Emby.Server.Implementations.AppBase;
|
using Emby.Server.Implementations.AppBase;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
|
@ -14,7 +13,7 @@ using Microsoft.Extensions.Logging;
|
||||||
namespace Emby.Server.Implementations.Configuration
|
namespace Emby.Server.Implementations.Configuration
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class ServerConfigurationManager
|
/// Class ServerConfigurationManager.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ServerConfigurationManager : BaseConfigurationManager, IServerConfigurationManager
|
public class ServerConfigurationManager : BaseConfigurationManager, IServerConfigurationManager
|
||||||
{
|
{
|
||||||
|
@ -62,13 +61,6 @@ namespace Emby.Server.Implementations.Configuration
|
||||||
base.OnConfigurationUpdated();
|
base.OnConfigurationUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddParts(IEnumerable<IConfigurationFactory> factories)
|
|
||||||
{
|
|
||||||
base.AddParts(factories);
|
|
||||||
|
|
||||||
UpdateTranscodePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the metadata path.
|
/// Updates the metadata path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -84,28 +76,6 @@ namespace Emby.Server.Implementations.Configuration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the transcoding temporary path.
|
|
||||||
/// </summary>
|
|
||||||
private void UpdateTranscodePath()
|
|
||||||
{
|
|
||||||
var encodingConfig = this.GetConfiguration<EncodingOptions>("encoding");
|
|
||||||
|
|
||||||
((ServerApplicationPaths)ApplicationPaths).TranscodePath = string.IsNullOrEmpty(encodingConfig.TranscodingTempPath) ?
|
|
||||||
null :
|
|
||||||
Path.Combine(encodingConfig.TranscodingTempPath, "transcodes");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnNamedConfigurationUpdated(string key, object configuration)
|
|
||||||
{
|
|
||||||
base.OnNamedConfigurationUpdated(key, configuration);
|
|
||||||
|
|
||||||
if (string.Equals(key, "encoding", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
UpdateTranscodePath();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces the configuration.
|
/// Replaces the configuration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -123,7 +93,6 @@ namespace Emby.Server.Implementations.Configuration
|
||||||
base.ReplaceConfiguration(newConfiguration);
|
base.ReplaceConfiguration(newConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the SSL certificate.
|
/// Validates the SSL certificate.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -582,11 +582,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
||||||
modelInfo.TunerCount,
|
modelInfo.TunerCount,
|
||||||
FileSystem,
|
FileSystem,
|
||||||
Logger,
|
Logger,
|
||||||
Config.ApplicationPaths,
|
Config,
|
||||||
_appHost,
|
_appHost,
|
||||||
_networkManager,
|
_networkManager,
|
||||||
_streamHelper);
|
_streamHelper);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var enableHttpStream = true;
|
var enableHttpStream = true;
|
||||||
|
@ -611,7 +610,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
||||||
FileSystem,
|
FileSystem,
|
||||||
_httpClient,
|
_httpClient,
|
||||||
Logger,
|
Logger,
|
||||||
Config.ApplicationPaths,
|
Config,
|
||||||
_appHost,
|
_appHost,
|
||||||
_streamHelper);
|
_streamHelper);
|
||||||
}
|
}
|
||||||
|
@ -624,7 +623,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
||||||
modelInfo.TunerCount,
|
modelInfo.TunerCount,
|
||||||
FileSystem,
|
FileSystem,
|
||||||
Logger,
|
Logger,
|
||||||
Config.ApplicationPaths,
|
Config,
|
||||||
_appHost,
|
_appHost,
|
||||||
_networkManager,
|
_networkManager,
|
||||||
_streamHelper);
|
_streamHelper);
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
|
@ -33,11 +34,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
||||||
int numTuners,
|
int numTuners,
|
||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
IServerApplicationPaths appPaths,
|
IConfigurationManager configurationManager,
|
||||||
IServerApplicationHost appHost,
|
IServerApplicationHost appHost,
|
||||||
INetworkManager networkManager,
|
INetworkManager networkManager,
|
||||||
IStreamHelper streamHelper)
|
IStreamHelper streamHelper)
|
||||||
: base(mediaSource, tunerHostInfo, fileSystem, logger, appPaths, streamHelper)
|
: base(mediaSource, tunerHostInfo, fileSystem, logger, configurationManager, streamHelper)
|
||||||
{
|
{
|
||||||
_appHost = appHost;
|
_appHost = appHost;
|
||||||
_networkManager = networkManager;
|
_networkManager = networkManager;
|
||||||
|
|
|
@ -5,8 +5,8 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller;
|
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.LiveTv;
|
using MediaBrowser.Model.LiveTv;
|
||||||
|
@ -16,8 +16,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
{
|
{
|
||||||
public class LiveStream : ILiveStream
|
public class LiveStream : ILiveStream
|
||||||
{
|
{
|
||||||
|
private readonly IConfigurationManager _configurationManager;
|
||||||
|
|
||||||
protected readonly IFileSystem FileSystem;
|
protected readonly IFileSystem FileSystem;
|
||||||
protected readonly IServerApplicationPaths AppPaths;
|
|
||||||
protected readonly IStreamHelper StreamHelper;
|
protected readonly IStreamHelper StreamHelper;
|
||||||
|
|
||||||
protected string TempFilePath;
|
protected string TempFilePath;
|
||||||
|
@ -29,7 +31,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
TunerHostInfo tuner,
|
TunerHostInfo tuner,
|
||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
IServerApplicationPaths appPaths,
|
IConfigurationManager configurationManager,
|
||||||
IStreamHelper streamHelper)
|
IStreamHelper streamHelper)
|
||||||
{
|
{
|
||||||
OriginalMediaSource = mediaSource;
|
OriginalMediaSource = mediaSource;
|
||||||
|
@ -44,7 +46,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
TunerHostId = tuner.Id;
|
TunerHostId = tuner.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppPaths = appPaths;
|
_configurationManager = configurationManager;
|
||||||
StreamHelper = streamHelper;
|
StreamHelper = streamHelper;
|
||||||
|
|
||||||
ConsumerCount = 1;
|
ConsumerCount = 1;
|
||||||
|
@ -68,7 +70,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
|
|
||||||
protected void SetTempFilePath(string extension)
|
protected void SetTempFilePath(string extension)
|
||||||
{
|
{
|
||||||
TempFilePath = Path.Combine(AppPaths.GetTranscodePath(), UniqueId + "." + extension);
|
TempFilePath = Path.Combine(_configurationManager.GetTranscodePath(), UniqueId + "." + extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Task Open(CancellationToken openCancellationToken)
|
public virtual Task Open(CancellationToken openCancellationToken)
|
||||||
|
|
|
@ -114,11 +114,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
|
|
||||||
if (!_disallowedSharedStreamExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
|
if (!_disallowedSharedStreamExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return new SharedHttpStream(mediaSource, info, streamId, FileSystem, _httpClient, Logger, Config.ApplicationPaths, _appHost, _streamHelper);
|
return new SharedHttpStream(mediaSource, info, streamId, FileSystem, _httpClient, Logger, Config, _appHost, _streamHelper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LiveStream(mediaSource, info, FileSystem, Logger, Config.ApplicationPaths, _streamHelper);
|
return new LiveStream(mediaSource, info, FileSystem, Logger, Config, _streamHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Validate(TunerHostInfo info)
|
public async Task Validate(TunerHostInfo info)
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
@ -26,10 +27,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
IHttpClient httpClient,
|
IHttpClient httpClient,
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
IServerApplicationPaths appPaths,
|
IConfigurationManager configurationManager,
|
||||||
IServerApplicationHost appHost,
|
IServerApplicationHost appHost,
|
||||||
IStreamHelper streamHelper)
|
IStreamHelper streamHelper)
|
||||||
: base(mediaSource, tunerHostInfo, fileSystem, logger, appPaths, streamHelper)
|
: base(mediaSource, tunerHostInfo, fileSystem, logger, configurationManager, streamHelper)
|
||||||
{
|
{
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
_appHost = appHost;
|
_appHost = appHost;
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Tasks;
|
using MediaBrowser.Model.Tasks;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
@ -15,24 +16,18 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DeleteTranscodeFileTask : IScheduledTask, IConfigurableScheduledTask
|
public class DeleteTranscodeFileTask : IScheduledTask, IConfigurableScheduledTask
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the application paths.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The application paths.</value>
|
|
||||||
private ServerApplicationPaths ApplicationPaths { get; set; }
|
|
||||||
|
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
private readonly IConfigurationManager _configurationManager;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="DeleteTranscodeFileTask" /> class.
|
/// Initializes a new instance of the <see cref="DeleteTranscodeFileTask" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DeleteTranscodeFileTask(ServerApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem)
|
public DeleteTranscodeFileTask(ILogger logger, IFileSystem fileSystem, IConfigurationManager configurationManager)
|
||||||
{
|
{
|
||||||
ApplicationPaths = appPaths;
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
_configurationManager = configurationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -52,14 +47,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
var minDateModified = DateTime.UtcNow.AddDays(-1);
|
var minDateModified = DateTime.UtcNow.AddDays(-1);
|
||||||
progress.Report(50);
|
progress.Report(50);
|
||||||
|
|
||||||
try
|
DeleteTempFilesFromDirectory(cancellationToken, _configurationManager.GetTranscodingTempPath(), minDateModified, progress);
|
||||||
{
|
|
||||||
DeleteTempFilesFromDirectory(cancellationToken, ApplicationPaths.TranscodePath, minDateModified, progress);
|
|
||||||
}
|
|
||||||
catch (DirectoryNotFoundException)
|
|
||||||
{
|
|
||||||
// No biggie here. Nothing to delete
|
|
||||||
}
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,40 +107,6 @@ namespace Emby.Server.Implementations
|
||||||
/// <value>The user configuration directory path.</value>
|
/// <value>The user configuration directory path.</value>
|
||||||
public string UserConfigurationDirectoryPath => Path.Combine(ConfigurationDirectoryPath, "users");
|
public string UserConfigurationDirectoryPath => Path.Combine(ConfigurationDirectoryPath, "users");
|
||||||
|
|
||||||
public string DefaultTranscodePath => _defaultTranscodePath ?? (_defaultTranscodePath = Path.Combine(ProgramDataPath, "transcodes"));
|
|
||||||
|
|
||||||
public string TranscodePath
|
|
||||||
{
|
|
||||||
get => _transcodePath ?? (_transcodePath = DefaultTranscodePath);
|
|
||||||
set => _transcodePath = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTranscodePath()
|
|
||||||
{
|
|
||||||
var path = TranscodePath;
|
|
||||||
|
|
||||||
if (!string.Equals(path, DefaultTranscodePath, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(path);
|
|
||||||
|
|
||||||
var testPath = Path.Combine(path, Guid.NewGuid().ToString());
|
|
||||||
Directory.CreateDirectory(testPath);
|
|
||||||
Directory.Delete(testPath);
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
path = DefaultTranscodePath;
|
|
||||||
Directory.CreateDirectory(path);
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string InternalMetadataPath
|
public string InternalMetadataPath
|
||||||
{
|
{
|
||||||
get => _internalMetadataPath ?? (_internalMetadataPath = Path.Combine(DataPath, "metadata"));
|
get => _internalMetadataPath ?? (_internalMetadataPath = Path.Combine(DataPath, "metadata"));
|
||||||
|
|
|
@ -13,7 +13,6 @@ using MediaBrowser.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Controller.Net;
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Controller.Plugins;
|
using MediaBrowser.Controller.Plugins;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
using MediaBrowser.Model.Configuration;
|
|
||||||
using MediaBrowser.Model.Diagnostics;
|
using MediaBrowser.Model.Diagnostics;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
|
@ -157,17 +156,12 @@ namespace MediaBrowser.Api
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EncodingOptions GetEncodingOptions()
|
|
||||||
{
|
|
||||||
return ConfigurationManagerExtensions.GetConfiguration<EncodingOptions>(ConfigurationManager, "encoding");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes the encoded media cache.
|
/// Deletes the encoded media cache.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void DeleteEncodedMediaCache()
|
private void DeleteEncodedMediaCache()
|
||||||
{
|
{
|
||||||
var path = ConfigurationManager.ApplicationPaths.GetTranscodePath();
|
var path = ConfigurationManager.GetTranscodePath();
|
||||||
|
|
||||||
if (!Directory.Exists(path))
|
if (!Directory.Exists(path))
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Devices;
|
using MediaBrowser.Controller.Devices;
|
||||||
|
@ -141,7 +142,7 @@ namespace MediaBrowser.Api.Playback
|
||||||
|
|
||||||
var filename = data.GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
var filename = data.GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||||
var ext = outputFileExtension.ToLowerInvariant();
|
var ext = outputFileExtension.ToLowerInvariant();
|
||||||
var folder = ServerConfigurationManager.ApplicationPaths.TranscodePath;
|
var folder = ServerConfigurationManager.GetTranscodePath();
|
||||||
|
|
||||||
if (EnableOutputInSubFolder)
|
if (EnableOutputInSubFolder)
|
||||||
{
|
{
|
||||||
|
@ -215,7 +216,7 @@ namespace MediaBrowser.Api.Playback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
|
var encodingOptions = ServerConfigurationManager.GetEncodingOptions();
|
||||||
|
|
||||||
var process = new Process()
|
var process = new Process()
|
||||||
{
|
{
|
||||||
|
@ -845,7 +846,7 @@ namespace MediaBrowser.Api.Playback
|
||||||
? GetOutputFileExtension(state)
|
? GetOutputFileExtension(state)
|
||||||
: ('.' + state.OutputContainer);
|
: ('.' + state.OutputContainer);
|
||||||
|
|
||||||
var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
|
var encodingOptions = ServerConfigurationManager.GetEncodingOptions();
|
||||||
|
|
||||||
state.OutputFilePath = GetOutputFilePath(state, encodingOptions, ext);
|
state.OutputFilePath = GetOutputFilePath(state, encodingOptions, ext);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.MediaEncoding;
|
using MediaBrowser.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Controller.Net;
|
using MediaBrowser.Controller.Net;
|
||||||
|
@ -83,13 +83,11 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
|
|
||||||
public class HlsSegmentService : BaseApiService
|
public class HlsSegmentService : BaseApiService
|
||||||
{
|
{
|
||||||
private readonly IServerApplicationPaths _appPaths;
|
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
|
||||||
public HlsSegmentService(IServerApplicationPaths appPaths, IServerConfigurationManager config, IFileSystem fileSystem)
|
public HlsSegmentService(IServerConfigurationManager config, IFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
_appPaths = appPaths;
|
|
||||||
_config = config;
|
_config = config;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +95,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
public Task<object> Get(GetHlsPlaylistLegacy request)
|
public Task<object> Get(GetHlsPlaylistLegacy request)
|
||||||
{
|
{
|
||||||
var file = request.PlaylistId + Path.GetExtension(Request.PathInfo);
|
var file = request.PlaylistId + Path.GetExtension(Request.PathInfo);
|
||||||
file = Path.Combine(_appPaths.TranscodePath, file);
|
file = Path.Combine(_config.GetTranscodePath(), file);
|
||||||
|
|
||||||
return GetFileResult(file, file);
|
return GetFileResult(file, file);
|
||||||
}
|
}
|
||||||
|
@ -115,8 +113,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
public Task<object> Get(GetHlsVideoSegmentLegacy request)
|
public Task<object> Get(GetHlsVideoSegmentLegacy request)
|
||||||
{
|
{
|
||||||
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
||||||
|
var transcodeFolderPath = _config.GetTranscodePath();
|
||||||
var transcodeFolderPath = _config.ApplicationPaths.TranscodePath;
|
|
||||||
file = Path.Combine(transcodeFolderPath, file);
|
file = Path.Combine(transcodeFolderPath, file);
|
||||||
|
|
||||||
var normalizedPlaylistId = request.PlaylistId;
|
var normalizedPlaylistId = request.PlaylistId;
|
||||||
|
@ -136,7 +133,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
{
|
{
|
||||||
// TODO: Deprecate with new iOS app
|
// TODO: Deprecate with new iOS app
|
||||||
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
||||||
file = Path.Combine(_appPaths.TranscodePath, file);
|
file = Path.Combine(_config.GetTranscodePath(), file);
|
||||||
|
|
||||||
return ResultFactory.GetStaticFileResult(Request, file, FileShareMode.ReadWrite);
|
return ResultFactory.GetStaticFileResult(Request, file, FileShareMode.ReadWrite);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System.IO;
|
||||||
|
using MediaBrowser.Model.Configuration;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Common.Configuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class containing extension methods for working with the encoding configuration.
|
||||||
|
/// </summary>
|
||||||
|
public static class EncodingConfigurationExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the encoding options.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configurationManager">The configuration manager.</param>
|
||||||
|
/// <returns>The encoding options.</returns>
|
||||||
|
public static EncodingOptions GetEncodingOptions(this IConfigurationManager configurationManager)
|
||||||
|
=> configurationManager.GetConfiguration<EncodingOptions>("encoding");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the transcoding temp path from the encoding configuration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configurationManager">The Configuration manager.</param>
|
||||||
|
/// <returns>The transcoding temp path.</returns>
|
||||||
|
public static string GetTranscodePath(this IConfigurationManager configurationManager)
|
||||||
|
=> configurationManager.GetEncodingOptions().TranscodingTempPath
|
||||||
|
?? Path.Combine(configurationManager.CommonApplicationPaths.ProgramDataPath, "transcoding-temp");
|
||||||
|
}
|
||||||
|
}
|
|
@ -82,12 +82,6 @@ namespace MediaBrowser.Controller
|
||||||
/// <value>The user configuration directory path.</value>
|
/// <value>The user configuration directory path.</value>
|
||||||
string UserConfigurationDirectoryPath { get; }
|
string UserConfigurationDirectoryPath { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the transcoding temporary path.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The transcoding temporary path.</value>
|
|
||||||
string TranscodePath { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the internal metadata path.
|
/// Gets the internal metadata path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -96,7 +90,5 @@ namespace MediaBrowser.Controller
|
||||||
string VirtualInternalMetadataPath { get; }
|
string VirtualInternalMetadataPath { get; }
|
||||||
|
|
||||||
string ArtistsPath { get; }
|
string ArtistsPath { get; }
|
||||||
|
|
||||||
string GetTranscodePath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Extensions;
|
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
|
|
||||||
|
|
|
@ -1,54 +1,46 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.IO;
|
|
||||||
|
|
||||||
namespace MediaBrowser.MediaEncoding.Configuration
|
namespace MediaBrowser.MediaEncoding.Configuration
|
||||||
{
|
{
|
||||||
public class EncodingConfigurationFactory : IConfigurationFactory
|
public class EncodingConfigurationFactory : IConfigurationFactory
|
||||||
{
|
{
|
||||||
private readonly IFileSystem _fileSystem;
|
|
||||||
|
|
||||||
public EncodingConfigurationFactory(IFileSystem fileSystem)
|
|
||||||
{
|
|
||||||
_fileSystem = fileSystem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<ConfigurationStore> GetConfigurations()
|
public IEnumerable<ConfigurationStore> GetConfigurations()
|
||||||
{
|
{
|
||||||
return new[]
|
return new[]
|
||||||
{
|
{
|
||||||
new EncodingConfigurationStore(_fileSystem)
|
new EncodingConfigurationStore()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EncodingConfigurationStore : ConfigurationStore, IValidatingConfiguration
|
public class EncodingConfigurationStore : ConfigurationStore, IValidatingConfiguration
|
||||||
{
|
{
|
||||||
private readonly IFileSystem _fileSystem;
|
public EncodingConfigurationStore()
|
||||||
|
|
||||||
public EncodingConfigurationStore(IFileSystem fileSystem)
|
|
||||||
{
|
{
|
||||||
ConfigurationType = typeof(EncodingOptions);
|
ConfigurationType = typeof(EncodingOptions);
|
||||||
Key = "encoding";
|
Key = "encoding";
|
||||||
_fileSystem = fileSystem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Validate(object oldConfig, object newConfig)
|
public void Validate(object oldConfig, object newConfig)
|
||||||
{
|
{
|
||||||
var oldEncodingConfig = (EncodingOptions)oldConfig;
|
var newPath = ((EncodingOptions)newConfig).TranscodingTempPath;
|
||||||
var newEncodingConfig = (EncodingOptions)newConfig;
|
|
||||||
|
|
||||||
var newPath = newEncodingConfig.TranscodingTempPath;
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(newPath)
|
if (!string.IsNullOrWhiteSpace(newPath)
|
||||||
&& !string.Equals(oldEncodingConfig.TranscodingTempPath ?? string.Empty, newPath))
|
&& !string.Equals(((EncodingOptions)oldConfig).TranscodingTempPath, newPath, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
// Validate
|
// Validate
|
||||||
if (!Directory.Exists(newPath))
|
if (!Directory.Exists(newPath))
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException(string.Format("{0} does not exist.", newPath));
|
throw new DirectoryNotFoundException(
|
||||||
|
string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"{0} does not exist.",
|
||||||
|
newPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user