From bd1578d60a0a7a454b60d7bfc0d2a4df023acff6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 28 Feb 2016 16:31:45 -0500 Subject: [PATCH 1/5] update components --- .../ScheduledTasks/ScheduledTaskService.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs index 949dac9261..d2da2ee846 100644 --- a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs +++ b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs @@ -6,6 +6,7 @@ using ServiceStack; using System; using System.Collections.Generic; using System.Linq; +using MediaBrowser.Controller.Configuration; namespace MediaBrowser.Api.ScheduledTasks { @@ -90,12 +91,14 @@ namespace MediaBrowser.Api.ScheduledTasks /// The task manager. private ITaskManager TaskManager { get; set; } + private readonly IServerConfigurationManager _config; + /// /// Initializes a new instance of the class. /// /// The task manager. - /// taskManager - public ScheduledTaskService(ITaskManager taskManager) + /// taskManager + public ScheduledTaskService(ITaskManager taskManager, IServerConfigurationManager config) { if (taskManager == null) { @@ -103,6 +106,7 @@ namespace MediaBrowser.Api.ScheduledTasks } TaskManager = taskManager; + _config = config; } /// @@ -194,6 +198,20 @@ namespace MediaBrowser.Api.ScheduledTasks throw new ResourceNotFoundException("Task not found"); } + var hasKey = task.ScheduledTask as IHasKey; + if (hasKey != null) + { + if (string.Equals(hasKey.Key, "SystemUpdateTask", StringComparison.OrdinalIgnoreCase)) + { + // This is a hack for now just to get the update application function to work when auto-update is disabled + if (!_config.Configuration.EnableAutoUpdate) + { + _config.Configuration.EnableAutoUpdate = true; + _config.SaveConfiguration(); + } + } + } + TaskManager.Execute(task); } From a9804ed2ef200d37aa999485aba4148386584e2f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 28 Feb 2016 16:31:54 -0500 Subject: [PATCH 2/5] use discover.json --- .../TunerHosts/HdHomerun/HdHomerunHost.cs | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 35988df9cd..bdfbee5217 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -96,30 +96,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun private async Task GetModelInfo(TunerHostInfo info, CancellationToken cancellationToken) { - string model = null; - using (var stream = await _httpClient.Get(new HttpRequestOptions() { - Url = string.Format("{0}/", GetApiUrl(info, false)), + Url = string.Format("{0}/discover.json", GetApiUrl(info, false)), CancellationToken = cancellationToken, CacheLength = TimeSpan.FromDays(1), CacheMode = CacheMode.Unconditional, TimeoutMs = Convert.ToInt32(TimeSpan.FromSeconds(5).TotalMilliseconds) })) { - using (var sr = new StreamReader(stream, System.Text.Encoding.UTF8)) - { - while (!sr.EndOfStream) - { - string line = StripXML(sr.ReadLine()); - if (line.StartsWith("Model:")) { model = line.Replace("Model: ", ""); } - //if (line.StartsWith("Device ID:")) { deviceID = line.Replace("Device ID: ", ""); } - //if (line.StartsWith("Firmware:")) { firmware = line.Replace("Firmware: ", ""); } - } - } - } + var response = JsonSerializer.DeserializeFromStream(stream); - return model; + return response.ModelNumber; + } } public async Task> GetTunerInfos(TunerHostInfo info, CancellationToken cancellationToken) @@ -438,5 +427,17 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun return info.Any(i => i.Status == LiveTvTunerStatus.Available); } + + public class DiscoverResponse + { + public string FriendlyName { get; set; } + public string ModelNumber { get; set; } + public string FirmwareName { get; set; } + public string FirmwareVersion { get; set; } + public string DeviceID { get; set; } + public string DeviceAuth { get; set; } + public string BaseURL { get; set; } + public string LineupURL { get; set; } + } } } From d0ca9b1c07d1021f69f768e99f765a2a6d185bda Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 29 Feb 2016 11:23:30 -0500 Subject: [PATCH 3/5] update components --- MediaBrowser.Api/Playback/Progressive/VideoService.cs | 2 ++ MediaBrowser.Controller/Providers/DirectoryService.cs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index 0af419cf33..f13058924e 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -36,6 +36,7 @@ namespace MediaBrowser.Api.Playback.Progressive [Route("/Videos/{Id}/stream.wmv", "GET")] [Route("/Videos/{Id}/stream.wtv", "GET")] [Route("/Videos/{Id}/stream.mov", "GET")] + [Route("/Videos/{Id}/stream.iso", "GET")] [Route("/Videos/{Id}/stream", "GET")] [Route("/Videos/{Id}/stream.ts", "HEAD")] [Route("/Videos/{Id}/stream.webm", "HEAD")] @@ -53,6 +54,7 @@ namespace MediaBrowser.Api.Playback.Progressive [Route("/Videos/{Id}/stream.wtv", "HEAD")] [Route("/Videos/{Id}/stream.m2ts", "HEAD")] [Route("/Videos/{Id}/stream.mov", "HEAD")] + [Route("/Videos/{Id}/stream.iso", "HEAD")] [Route("/Videos/{Id}/stream", "HEAD")] [Api(Description = "Gets a video stream")] public class GetVideoStream : VideoStreamRequest diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs index 36ef6ca1f0..2192ebcaca 100644 --- a/MediaBrowser.Controller/Providers/DirectoryService.cs +++ b/MediaBrowser.Controller/Providers/DirectoryService.cs @@ -63,7 +63,8 @@ namespace MediaBrowser.Controller.Providers try { // using EnumerateFileSystemInfos doesn't handle reparse points (symlinks) - var list = _fileSystem.GetFileSystemEntries(path); + var list = _fileSystem.GetFileSystemEntries(path) + .ToList(); // Seeing dupes on some users file system for some reason foreach (var item in list) From bd38cb7a8b3bb8dcb9cf44d75aae60930a0dedf1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 29 Feb 2016 11:25:09 -0500 Subject: [PATCH 4/5] update EpisodeFileOrganizer --- .../FileOrganization/EpisodeFileOrganizer.cs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs index 24e8c71374..f9e167a8f7 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs @@ -286,16 +286,29 @@ namespace MediaBrowser.Server.Implementations.FileOrganization { if (options.TvOptions.CopyOriginalFile && fileExists && IsSameEpisode(sourcePath, newPath)) { - _logger.Info("File {0} already copied to new path {1}, stopping organization", sourcePath, newPath); + var msg = string.Format("File '{0}' already copied to new path '{1}', stopping organization", sourcePath, newPath); + _logger.Info(msg); result.Status = FileSortingStatus.SkippedExisting; - result.StatusMessage = string.Empty; + result.StatusMessage = msg; + return; + } + + if (fileExists) + { + var msg = string.Format("File '{0}' already exists as '{1}', stopping organization", sourcePath, newPath); + _logger.Info(msg); + result.Status = FileSortingStatus.SkippedExisting; + result.StatusMessage = msg; + result.TargetPath = newPath; return; } - if (fileExists || otherDuplicatePaths.Count > 0) + if (otherDuplicatePaths.Count > 0) { + var msg = string.Format("File '{0}' already exists as '{1}', stopping organization", sourcePath, otherDuplicatePaths); + _logger.Info(msg); result.Status = FileSortingStatus.SkippedExisting; - result.StatusMessage = string.Empty; + result.StatusMessage = msg; result.DuplicatePaths = otherDuplicatePaths; return; } From 6da57c86cd0b0955b5fc9a4426762cc83328eeff Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 29 Feb 2016 11:25:21 -0500 Subject: [PATCH 5/5] update recordings --- MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs | 2 +- .../LiveTv/EmbyTV/EncodedRecorder.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 1fbd3cb3e5..e534d8c675 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -778,7 +778,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV try { // HDHR doesn't seem to release the tuner right away after first probing with ffmpeg - await Task.Delay(3000, cancellationToken).ConfigureAwait(false); + //await Task.Delay(3000, cancellationToken).ConfigureAwait(false); var duration = recordingEndDate - DateTime.UtcNow; diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs index ac5cda95ea..8b7bd897b9 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs @@ -88,11 +88,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV // MUST read both stdout and stderr asynchronously or a deadlock may occurr process.BeginOutputReadLine(); + onStarted(); + // Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback StartStreamingLog(process.StandardError.BaseStream, _logFileStream); - onStarted(); - // Wait for the file to exist before proceeeding while (!_hasExited) {