From 84ec2aab951ced678876ebc53f43cc85f83012d7 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 7 Apr 2015 13:51:14 -0400 Subject: [PATCH] fix video probing --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 11 ++++++++--- MediaBrowser.Api/Playback/TranscodingThrottler.cs | 2 +- .../Probing/ProbeResultNormalizer.cs | 5 +++++ .../Localization/JavaScript/javascript.json | 1 + OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs | 6 ++++-- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 75321f872c..a8aa18367c 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1624,14 +1624,19 @@ namespace MediaBrowser.Api.Playback var archivable = item as IArchivable; state.IsInputArchive = archivable != null && archivable.IsArchive; - MediaSourceInfo mediaSource = null; + MediaSourceInfo mediaSource; if (string.IsNullOrWhiteSpace(request.LiveStreamId)) { - var mediaSources = await MediaSourceManager.GetPlayackMediaSources(request.Id, false, cancellationToken).ConfigureAwait(false); + var mediaSources = (await MediaSourceManager.GetPlayackMediaSources(request.Id, false, cancellationToken).ConfigureAwait(false)).ToList(); mediaSource = string.IsNullOrEmpty(request.MediaSourceId) ? mediaSources.First() - : mediaSources.First(i => string.Equals(i.Id, request.MediaSourceId)); + : mediaSources.FirstOrDefault(i => string.Equals(i.Id, request.MediaSourceId)); + + if (mediaSource == null && string.Equals(request.Id, request.MediaSourceId, StringComparison.OrdinalIgnoreCase)) + { + mediaSource = mediaSources.First(); + } } else { diff --git a/MediaBrowser.Api/Playback/TranscodingThrottler.cs b/MediaBrowser.Api/Playback/TranscodingThrottler.cs index ff79bb48f4..58cfa086e3 100644 --- a/MediaBrowser.Api/Playback/TranscodingThrottler.cs +++ b/MediaBrowser.Api/Playback/TranscodingThrottler.cs @@ -42,7 +42,7 @@ namespace MediaBrowser.Api.Playback var options = GetOptions(); - if (/*options.EnableThrottling &&*/ IsThrottleAllowed(_job, options.ThrottleThresholdSeconds)) + if (options.EnableThrottling && IsThrottleAllowed(_job, options.ThrottleThresholdSeconds)) { PauseTranscoding(); } diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index 7df3cb56f1..267ff875a9 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -63,6 +63,11 @@ namespace MediaBrowser.MediaEncoding.Probing } else { + if (data.format != null && !string.IsNullOrEmpty(data.format.duration)) + { + info.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.format.duration, _usCulture)).Ticks; + } + FetchWtvInfo(info, data); if (data.Chapters != null) diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index f0f7ba36fe..f782a1f680 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -199,6 +199,7 @@ "HeaderSplitMedia": "Split Media Apart", "MessageConfirmSplitMedia": "Are you sure you wish to split the media sources into separate items?", "HeaderError": "Error", + "MessageChromecastConnectionError": "Your Chromecast receiver is unable to connect to your Emby Server. Please check their connections and try again.", "MessagePleaseSelectOneItem": "Please select at least one item.", "MessagePleaseSelectTwoItems": "Please select at least two items.", "MessageTheFollowingItemsWillBeGrouped": "The following titles will be grouped into one item:", diff --git a/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs b/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs index 76096a5416..5a190ab729 100644 --- a/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs +++ b/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs @@ -51,8 +51,10 @@ namespace XmlRpcHandler XmlWriterSettings sett = new XmlWriterSettings(); sett.Indent = true; + var requestXmlPath = Path.Combine(Path.GetTempPath(), "request.xml"); + sett.Encoding = Encoding.UTF8; - FileStream str = new FileStream(Path.GetTempPath() + "\\request.xml", FileMode.Create, FileAccess.Write); + FileStream str = new FileStream(requestXmlPath, FileMode.Create, FileAccess.Write); XmlWriter XMLwrt = XmlWriter.Create(str, sett); // Let's write the methods @@ -88,7 +90,7 @@ namespace XmlRpcHandler XMLwrt.Flush(); XMLwrt.Close(); str.Close(); - string requestContent = File.ReadAllText(Path.GetTempPath() + "\\request.xml"); + string requestContent = File.ReadAllText(requestXmlPath); return Encoding.UTF8.GetBytes(requestContent); } ///