From c418f94c98658413ebb078154b7041d3d809ba40 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 22 Nov 2016 14:45:55 -0500 Subject: [PATCH] add recording post processing option --- .../LiveTv/EmbyTV/EmbyTV.cs | 44 +++++++++++++++++++ MediaBrowser.Model/LiveTv/LiveTvOptions.cs | 4 ++ 2 files changed, 48 insertions(+) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 81a6b8508c..b7d2d1748d 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -38,6 +38,7 @@ using MediaBrowser.Model.Diagnostics; using MediaBrowser.Model.FileOrganization; using MediaBrowser.Model.System; using MediaBrowser.Model.Threading; +using MediaBrowser.Model.Extensions; namespace Emby.Server.Implementations.LiveTv.EmbyTV { @@ -1550,6 +1551,49 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV // _logger.ErrorException("Error processing new recording", ex); // } //} + PostProcessRecording(timer, path); + } + + private void PostProcessRecording(TimerInfo timer, string path) + { + var options = GetConfiguration(); + if (string.IsNullOrWhiteSpace(options.RecordingPostProcessor)) + { + return; + } + + try + { + var process = _processFactory.Create(new ProcessOptions + { + Arguments = GetPostProcessArguments(path, options.RecordingPostProcessorArguments), + CreateNoWindow = true, + EnableRaisingEvents = true, + ErrorDialog = false, + FileName = options.RecordingPostProcessor, + IsHidden = true, + UseShellExecute = true + }); + + _logger.Info("Running recording post processor {0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + + process.Exited += Process_Exited; + process.Start(); + } + catch (Exception ex) + { + _logger.ErrorException("Error running recording post processor", ex); + } + } + + private string GetPostProcessArguments(string path, string arguments) + { + return arguments.Replace("{path}", path, StringComparison.OrdinalIgnoreCase); + } + + private void Process_Exited(object sender, EventArgs e) + { + ((IProcess)sender).Dispose(); } private void SaveNfo(TimerInfo timer, string recordingPath, string seriesPath) diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index cc5148ba95..8f7e94cf02 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -26,6 +26,9 @@ namespace MediaBrowser.Model.LiveTv public string[] MediaLocationsCreated { get; set; } + public string RecordingPostProcessor { get; set; } + public string RecordingPostProcessorArguments { get; set; } + public LiveTvOptions() { EnableMovieProviders = true; @@ -34,6 +37,7 @@ namespace MediaBrowser.Model.LiveTv ListingProviders = new List(); MediaLocationsCreated = new string[] { }; RecordingEncodingFormat = "mp4"; + RecordingPostProcessorArguments = "\"{path}\""; } }