mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
update path configs
This commit is contained in:
parent
db1130166f
commit
775fc94020
@ -79,6 +79,8 @@ namespace MediaBrowser.Api
|
|||||||
{
|
{
|
||||||
[ApiMember(Name = "Path", Description = "Path", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
[ApiMember(Name = "Path", Description = "Path", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
[ApiMember(Name = "PathType", Description = "PathType", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||||
|
public string PathType { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConfigurationService : BaseApiService
|
public class ConfigurationService : BaseApiService
|
||||||
@ -110,7 +112,7 @@ namespace MediaBrowser.Api
|
|||||||
|
|
||||||
public void Post(UpdateMediaEncoderPath request)
|
public void Post(UpdateMediaEncoderPath request)
|
||||||
{
|
{
|
||||||
var task = _mediaEncoder.UpdateEncoderPath(request.Path);
|
var task = _mediaEncoder.UpdateEncoderPath(request.Path, request.PathType);
|
||||||
Task.WaitAll(task);
|
Task.WaitAll(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMediaEncoder : ITranscoderSupport
|
public interface IMediaEncoder : ITranscoderSupport
|
||||||
{
|
{
|
||||||
|
string EncoderLocationType { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the encoder path.
|
/// Gets the encoder path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -131,6 +133,6 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
Task UpdateEncoderPath(string path);
|
Task UpdateEncoderPath(string path, string pathType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,39 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
_hasExternalEncoder = hasExternalEncoder;
|
_hasExternalEncoder = hasExternalEncoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string EncoderLocationType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_hasExternalEncoder)
|
||||||
|
{
|
||||||
|
return "External";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(FFMpegPath))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsSystemInstalledPath(FFMpegPath))
|
||||||
|
{
|
||||||
|
return "System";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Custom";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsSystemInstalledPath(string path)
|
||||||
|
{
|
||||||
|
if (path.IndexOf("/", StringComparison.Ordinal) == -1 && path.IndexOf("\\", StringComparison.Ordinal) == -1)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
ConfigureEncoderPaths();
|
ConfigureEncoderPaths();
|
||||||
@ -115,11 +148,14 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
|
|
||||||
var valueToSave = FFMpegPath;
|
var valueToSave = FFMpegPath;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(valueToSave))
|
||||||
|
{
|
||||||
// if using system variable, don't save this.
|
// if using system variable, don't save this.
|
||||||
if (string.Equals(valueToSave, "ffmpeg", StringComparison.OrdinalIgnoreCase))
|
if (IsSystemInstalledPath(valueToSave))
|
||||||
{
|
{
|
||||||
valueToSave = null;
|
valueToSave = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.Equals(valueToSave, appPath, StringComparison.Ordinal))
|
if (!string.Equals(valueToSave, appPath, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
@ -128,7 +164,22 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateEncoderPath(string path)
|
public async Task UpdateEncoderPath(string path, string pathType)
|
||||||
|
{
|
||||||
|
if (_hasExternalEncoder)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tuple<string, string> newPaths;
|
||||||
|
|
||||||
|
if (string.Equals(pathType, "system", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
path = "ffmpeg";
|
||||||
|
|
||||||
|
newPaths = TestForInstalledVersions();
|
||||||
|
}
|
||||||
|
else if (string.Equals(pathType, "custom", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(path))
|
if (string.IsNullOrWhiteSpace(path))
|
||||||
{
|
{
|
||||||
@ -139,8 +190,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
{
|
{
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException();
|
||||||
}
|
}
|
||||||
|
newPaths = GetEncoderPaths(path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Unexpected pathType value");
|
||||||
|
}
|
||||||
|
|
||||||
var newPaths = GetEncoderPaths(path);
|
|
||||||
if (string.IsNullOrWhiteSpace(newPaths.Item1))
|
if (string.IsNullOrWhiteSpace(newPaths.Item1))
|
||||||
{
|
{
|
||||||
throw new ResourceNotFoundException("ffmpeg not found");
|
throw new ResourceNotFoundException("ffmpeg not found");
|
||||||
|
@ -152,7 +152,7 @@ namespace MediaBrowser.Model.System
|
|||||||
/// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>
|
/// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>
|
||||||
public bool SupportsAutoRunAtStartup { get; set; }
|
public bool SupportsAutoRunAtStartup { get; set; }
|
||||||
|
|
||||||
public bool HasExternalEncoder { get; set; }
|
public string EncoderLocationType { get; set; }
|
||||||
|
|
||||||
public Architecture SystemArchitecture { get; set; }
|
public Architecture SystemArchitecture { get; set; }
|
||||||
|
|
||||||
|
@ -658,13 +658,13 @@ namespace MediaBrowser.Server.Startup.Common
|
|||||||
|
|
||||||
encoderPath = info.EncoderPath;
|
encoderPath = info.EncoderPath;
|
||||||
probePath = info.ProbePath;
|
probePath = info.ProbePath;
|
||||||
_hasExternalEncoder = string.Equals(info.Version, "external", StringComparison.OrdinalIgnoreCase);
|
var hasExternalEncoder = string.Equals(info.Version, "external", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
var mediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"),
|
var mediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"),
|
||||||
JsonSerializer,
|
JsonSerializer,
|
||||||
encoderPath,
|
encoderPath,
|
||||||
probePath,
|
probePath,
|
||||||
_hasExternalEncoder,
|
hasExternalEncoder,
|
||||||
ServerConfigurationManager,
|
ServerConfigurationManager,
|
||||||
FileSystemManager,
|
FileSystemManager,
|
||||||
LiveTvManager,
|
LiveTvManager,
|
||||||
@ -1100,7 +1100,6 @@ namespace MediaBrowser.Server.Startup.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _hasExternalEncoder;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the system status.
|
/// Gets the system status.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -1141,7 +1140,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||||||
ServerName = FriendlyName,
|
ServerName = FriendlyName,
|
||||||
LocalAddress = localAddress,
|
LocalAddress = localAddress,
|
||||||
SupportsLibraryMonitor = SupportsLibraryMonitor,
|
SupportsLibraryMonitor = SupportsLibraryMonitor,
|
||||||
HasExternalEncoder = _hasExternalEncoder,
|
EncoderLocationType = MediaEncoder.EncoderLocationType,
|
||||||
SystemArchitecture = NativeApp.Environment.SystemArchitecture
|
SystemArchitecture = NativeApp.Environment.SystemArchitecture
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user