From 318534d4761682d74474d54cc76fe950ea4fc92f Mon Sep 17 00:00:00 2001 From: Avalon Thorne Date: Tue, 14 Jun 2016 05:13:38 -0400 Subject: [PATCH 1/2] Disable FIPS Validation Check in App.config Disables the FIPS Validation Check to allow the MediaBrowser Server Application to run on a Trusted Platform enabled computer running Windows 10. Important information regarding the addition can be found on MSDN: https://msdn.microsoft.com/en-us/library/hh202806(v=vs.110).aspx While in our discussions with Microsoft Government and Enterprise Support it has been indicated that it's best practice to move to a FIPS validated encryption method (please see MSDN: https://msdn.microsoft.com/en-us/library/0ss79b2x(v=vs.110).aspx to determine an appropriate algorithm), this patch will at minimum allow the application to run by specifying whether to enforce a computer configuration requirement that cryptographic algorithms must comply with the Federal Information Processing Standards or "FIPS." Please see http://emby.media/community/index.php?/topic/35875-fips-validated-cryptography-fix/ for discussion on the proposed fix. --- MediaBrowser.ServerApplication/App.config | 1 + 1 file changed, 1 insertion(+) diff --git a/MediaBrowser.ServerApplication/App.config b/MediaBrowser.ServerApplication/App.config index a92d923007..6d840c1910 100644 --- a/MediaBrowser.ServerApplication/App.config +++ b/MediaBrowser.ServerApplication/App.config @@ -52,6 +52,7 @@ + From 66c86ccc58d1022bdb65d63b47df82845ad921c7 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 14 Jun 2016 15:21:26 -0400 Subject: [PATCH 2/2] update pooling --- .../HttpServer/LoggerUtils.cs | 2 +- .../LiveTv/Listings/XmlTvListingsProvider.cs | 6 +- .../Persistence/SqliteExtensions.cs | 2 +- .../TV/TVSeriesManager.cs | 101 +++++++++++------- 4 files changed, 67 insertions(+), 44 deletions(-) diff --git a/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs b/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs index ce81000254..bfbb228edf 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs @@ -35,7 +35,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer public static void LogResponse(ILogger logger, int statusCode, string url, string endPoint, TimeSpan duration) { var durationMs = duration.TotalMilliseconds; - var logSuffix = durationMs >= 1000 ? "ms (slow)" : "ms"; + var logSuffix = durationMs >= 1000 && durationMs < 60000 ? "ms (slow)" : "ms"; logger.Info("HTTP Response {0} to {1}. Time: {2}{3}. {4}", statusCode, endPoint, Convert.ToInt32(durationMs).ToString(CultureInfo.InvariantCulture), logSuffix, url); } diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index 1628ddc019..07affb865c 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -45,6 +45,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings private async Task GetXml(string path, CancellationToken cancellationToken) { + _logger.Info("xmltv path: {0}", path); + if (!path.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { return path; @@ -161,7 +163,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings { Id = c.Id, Name = c.DisplayName, - ImageUrl = c.Icon != null && !String.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null + ImageUrl = c.Icon != null && !String.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null, + Number = c.Id + }).ToList(); } } diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs index 40cac82c32..73b3a22531 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs @@ -35,7 +35,7 @@ namespace MediaBrowser.Server.Implementations.Persistence JournalMode = SQLiteJournalModeEnum.Wal, // This is causing crashing under linux - Pooling = Environment.OSVersion.Platform == PlatformID.Win32NT, + Pooling = enablePooling && Environment.OSVersion.Platform == PlatformID.Win32NT, ReadOnly = isReadOnly }; diff --git a/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs b/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs index d57aea08e2..4aff3b6ef3 100644 --- a/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs +++ b/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs @@ -124,58 +124,77 @@ namespace MediaBrowser.Server.Implementations.TV /// Task{Episode}. private Tuple GetNextUp(Series series, User user) { - // Get them in display order, then reverse - var allEpisodes = series.GetEpisodes(user, false, false) - .Where(i => !i.ParentIndexNumber.HasValue || i.ParentIndexNumber.Value != 0) - .Reverse() - .ToList(); - - Episode lastWatched = null; - var lastWatchedDate = DateTime.MinValue; - Episode nextUp = null; - - var unplayedEpisodes = new List(); - - // Go back starting with the most recent episodes - foreach (var episode in allEpisodes) + var firstUnwatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user) { - var userData = _userDataManager.GetUserData(user, episode); - - if (userData.Played) - { - if (lastWatched != null || nextUp == null) - { - break; - } - - lastWatched = episode; - lastWatchedDate = userData.LastPlayedDate ?? DateTime.MinValue; - } - else - { - unplayedEpisodes.Add(episode); + AncestorWithPresentationUniqueKey = series.PresentationUniqueKey, + IncludeItemTypes = new[] { typeof(Episode).Name }, + SortBy = new[] { ItemSortBy.SortName }, + SortOrder = SortOrder.Ascending, + Limit = 1, + IsPlayed = false, + IsVirtualItem = false - nextUp = episode; - } - } + }).Cast().FirstOrDefault(); - if (lastWatched != null) + if (firstUnwatchedEpisode == null) { - return new Tuple(nextUp, lastWatchedDate, false); + return new Tuple(null, DateTime.MinValue, true); } - Episode firstEpisode = null; - // Find the first unplayed episode. Start from the back of the list since they're in reverse order - for (var i = unplayedEpisodes.Count - 1; i >= 0; i--) + var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user) { - var unplayedEpisode = unplayedEpisodes[i]; + AncestorWithPresentationUniqueKey = series.PresentationUniqueKey, + IncludeItemTypes = new[] { typeof(Episode).Name }, + SortBy = new[] { ItemSortBy.DatePlayed }, + SortOrder = SortOrder.Descending, + Limit = 1, + IsVirtualItem = false + + }).FirstOrDefault(); + + //// Get them in display order, then reverse + //var allEpisodes = series.GetEpisodes(user, false, false) + // .Where(i => !i.ParentIndexNumber.HasValue || i.ParentIndexNumber.Value != 0) + // .Reverse() + // .ToList(); + + //Episode lastWatched = null; + //var lastWatchedDate = DateTime.MinValue; + //Episode nextUp = null; + + //// Go back starting with the most recent episodes + //foreach (var episode in allEpisodes) + //{ + // var userData = _userDataManager.GetUserData(user, episode); + + // if (userData.Played) + // { + // if (lastWatched != null || nextUp == null) + // { + // break; + // } + + // lastWatched = episode; + // lastWatchedDate = userData.LastPlayedDate ?? DateTime.MinValue; + // } + // else + // { + // nextUp = episode; + // } + //} + + if (lastWatchedEpisode != null) + { + var userData = _userDataManager.GetUserData(user, lastWatchedEpisode); - firstEpisode = unplayedEpisode; - break; + if (userData.LastPlayedDate.HasValue) + { + return new Tuple(firstUnwatchedEpisode, userData.LastPlayedDate.Value, false); + } } // Return the first episode - return new Tuple(firstEpisode, DateTime.MinValue, true); + return new Tuple(firstUnwatchedEpisode, DateTime.MinValue, true); } private QueryResult GetResult(IEnumerable items, int? totalRecordLimit, NextUpQuery query)