From eee9c0e0489087f4a8f611165e547f8f2dd353d5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Sep 2016 02:57:31 -0400 Subject: [PATCH] update recording dialogs --- .../ScheduledTasks/ScheduledTaskWorker.cs | 2 +- .../Encoder/EncoderValidator.cs | 24 ++++++++ .../Encoder/MediaEncoder.cs | 55 ++++++++----------- .../Manager/MetadataService.cs | 7 +++ .../Persistence/SqliteItemRepository.cs | 9 ++- 5 files changed, 63 insertions(+), 34 deletions(-) diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index 446e399bda..ced85780f8 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -334,7 +334,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks trigger.Stop(); - TaskManager.QueueScheduledTask(ScheduledTask); + TaskManager.QueueScheduledTask(ScheduledTask, e.Argument); await Task.Delay(1000).ConfigureAwait(false); diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index a450097fd2..24de4e77e2 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -26,6 +26,30 @@ namespace MediaBrowser.MediaEncoding.Encoder return new Tuple, List>(decoders, encoders); } + public bool ValidateVersion(string encoderAppPath) + { + string output = string.Empty; + try + { + output = GetProcessOutput(encoderAppPath, "-version"); + } + catch + { + } + + if (string.IsNullOrWhiteSpace(output)) + { + return false; + } + + if (output.IndexOf("Libav developers", StringComparison.OrdinalIgnoreCase) != -1) + { + return false; + } + + return true; + } + private List GetDecoders(string encoderAppPath) { string output = string.Empty; diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index b2c2b71f84..d3131eb5a8 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -82,6 +82,8 @@ namespace MediaBrowser.MediaEncoding.Encoder private readonly List _runningProcesses = new List(); private readonly bool _hasExternalEncoder; + private string _originalFFMpegPath; + private string _originalFFProbePath; public MediaEncoder(ILogger logger, IJsonSerializer jsonSerializer, string ffMpegPath, string ffProbePath, bool hasExternalEncoder, IServerConfigurationManager configurationManager, IFileSystem fileSystem, ILiveTvManager liveTvManager, IIsoManager isoManager, ILibraryManager libraryManager, IChannelManager channelManager, ISessionManager sessionManager, Func subtitleEncoder, Func mediaSourceManager, IHttpClient httpClient, IZipClient zipClient) { @@ -100,6 +102,8 @@ namespace MediaBrowser.MediaEncoding.Encoder _zipClient = zipClient; FFProbePath = ffProbePath; FFMpegPath = ffMpegPath; + _originalFFProbePath = ffProbePath; + _originalFFMpegPath = ffMpegPath; _hasExternalEncoder = hasExternalEncoder; } @@ -231,6 +235,11 @@ namespace MediaBrowser.MediaEncoding.Encoder throw new ResourceNotFoundException("ffprobe not found"); } + if (!ValidateVersion(path)) + { + throw new ResourceNotFoundException("ffmpeg version 3.0 or greater is required."); + } + var config = GetEncodingOptions(); config.EncoderAppPath = path; ConfigurationManager.SaveConfiguration("encoding", config); @@ -238,6 +247,11 @@ namespace MediaBrowser.MediaEncoding.Encoder Init(); } + private bool ValidateVersion(string path) + { + return new EncoderValidator(_logger).ValidateVersion(path); + } + private void ConfigureEncoderPaths() { var appPath = GetEncodingOptions().EncoderAppPath; @@ -287,45 +301,22 @@ namespace MediaBrowser.MediaEncoding.Encoder string encoderPath = null; string probePath = null; - if (TestSystemInstalled("ffmpeg")) + if (_hasExternalEncoder && ValidateVersion(_originalFFMpegPath)) { - encoderPath = "ffmpeg"; + encoderPath = _originalFFMpegPath; + probePath = _originalFFProbePath; } - if (TestSystemInstalled("ffprobe")) - { - probePath = "ffprobe"; - } - - return new Tuple(encoderPath, probePath); - } - private bool TestSystemInstalled(string app) - { - try + if (string.IsNullOrWhiteSpace(encoderPath)) { - var startInfo = new ProcessStartInfo + if (ValidateVersion("ffmpeg") && ValidateVersion("ffprobe")) { - FileName = app, - Arguments = "-v", - UseShellExecute = false, - CreateNoWindow = true, - WindowStyle = ProcessWindowStyle.Hidden, - ErrorDialog = false - }; - - using (var process = Process.Start(startInfo)) - { - process.WaitForExit(); + encoderPath = "ffmpeg"; + probePath = "ffprobe"; } - - _logger.Debug("System app installed: " + app); - return true; - } - catch - { - _logger.Debug("System app not installed: " + app); - return false; } + + return new Tuple(encoderPath, probePath); } private Tuple GetPathsFromDirectory(string path) diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index e16e76bfcc..18405aae91 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -316,6 +316,13 @@ namespace MediaBrowser.Providers.Manager updateType |= ItemUpdateType.MetadataImport; } + var inheritedTags = item.GetInheritedTags(); + if (!inheritedTags.SequenceEqual(item.InheritedTags, StringComparer.Ordinal)) + { + item.InheritedTags = inheritedTags; + updateType |= ItemUpdateType.MetadataImport; + } + return updateType; } diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 5ece3dd826..05c2826876 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -412,7 +412,8 @@ namespace MediaBrowser.Server.Implementations.Persistence "SeriesId", "SeriesSortName", "PresentationUniqueKey", - "InheritedParentalRatingValue" + "InheritedParentalRatingValue", + "InheritedTags" }; private readonly string[] _mediaStreamSaveColumns = @@ -1459,6 +1460,12 @@ namespace MediaBrowser.Server.Implementations.Persistence } index++; + if (!reader.IsDBNull(index)) + { + item.InheritedTags = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(); + } + index++; + return item; }