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); + AncestorWithPresentationUniqueKey = series.PresentationUniqueKey, + IncludeItemTypes = new[] { typeof(Episode).Name }, + SortBy = new[] { ItemSortBy.SortName }, + SortOrder = SortOrder.Ascending, + Limit = 1, + IsPlayed = false, + IsVirtualItem = false - if (userData.Played) - { - if (lastWatched != null || nextUp == null) - { - break; - } + }).Cast().FirstOrDefault(); - lastWatched = episode; - lastWatchedDate = userData.LastPlayedDate ?? DateTime.MinValue; - } - else - { - unplayedEpisodes.Add(episode); - - nextUp = episode; - } + if (firstUnwatchedEpisode == null) + { + return new Tuple(null, DateTime.MinValue, true); } - if (lastWatched != null) + var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user) { - return new Tuple(nextUp, lastWatchedDate, false); - } + AncestorWithPresentationUniqueKey = series.PresentationUniqueKey, + IncludeItemTypes = new[] { typeof(Episode).Name }, + SortBy = new[] { ItemSortBy.DatePlayed }, + SortOrder = SortOrder.Descending, + Limit = 1, + IsVirtualItem = false - 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--) + }).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 unplayedEpisode = unplayedEpisodes[i]; + 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) 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 @@ +