mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-12 02:30:23 +01:00
next up upgrade fixes
This commit is contained in:
@@ -526,16 +526,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return key.GetMD5();
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> ReplaceVideosWithPrimaryVersions(IEnumerable<BaseItem> items)
|
||||
{
|
||||
if (items == null)
|
||||
{
|
||||
throw new ArgumentNullException("items");
|
||||
}
|
||||
|
||||
return items.DistinctBy(i => i.PresentationUniqueKey, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure supplied item has only one instance throughout
|
||||
/// </summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ using MediaBrowser.Model.Querying;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.TV
|
||||
{
|
||||
@@ -15,12 +16,14 @@ namespace MediaBrowser.Server.Implementations.TV
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IUserDataManager _userDataManager;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
|
||||
public TVSeriesManager(IUserManager userManager, IUserDataManager userDataManager, ILibraryManager libraryManager)
|
||||
public TVSeriesManager(IUserManager userManager, IUserDataManager userDataManager, ILibraryManager libraryManager, IServerConfigurationManager config)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_userDataManager = userDataManager;
|
||||
_libraryManager = libraryManager;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public QueryResult<BaseItem> GetNextUp(NextUpQuery request)
|
||||
@@ -42,7 +45,7 @@ namespace MediaBrowser.Server.Implementations.TV
|
||||
|
||||
if (series != null)
|
||||
{
|
||||
presentationUniqueKey = series.PresentationUniqueKey;
|
||||
presentationUniqueKey = GetUniqueSeriesKey(series);
|
||||
limit = 1;
|
||||
}
|
||||
}
|
||||
@@ -81,7 +84,7 @@ namespace MediaBrowser.Server.Implementations.TV
|
||||
|
||||
if (series != null)
|
||||
{
|
||||
presentationUniqueKey = series.PresentationUniqueKey;
|
||||
presentationUniqueKey = GetUniqueSeriesKey(series);
|
||||
limit = 1;
|
||||
}
|
||||
}
|
||||
@@ -115,6 +118,15 @@ namespace MediaBrowser.Server.Implementations.TV
|
||||
.Select(i => i.Item1);
|
||||
}
|
||||
|
||||
private string GetUniqueSeriesKey(BaseItem series)
|
||||
{
|
||||
if (_config.Configuration.SchemaVersion < 97)
|
||||
{
|
||||
return series.Id.ToString("N");
|
||||
}
|
||||
return series.PresentationUniqueKey;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the next up.
|
||||
/// </summary>
|
||||
@@ -125,7 +137,7 @@ namespace MediaBrowser.Server.Implementations.TV
|
||||
{
|
||||
var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
|
||||
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(series),
|
||||
IncludeItemTypes = new[] { typeof(Episode).Name },
|
||||
SortBy = new[] { ItemSortBy.SortName },
|
||||
SortOrder = SortOrder.Descending,
|
||||
@@ -138,7 +150,7 @@ namespace MediaBrowser.Server.Implementations.TV
|
||||
|
||||
var firstUnwatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
|
||||
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(series),
|
||||
IncludeItemTypes = new[] { typeof(Episode).Name },
|
||||
SortBy = new[] { ItemSortBy.SortName },
|
||||
SortOrder = SortOrder.Ascending,
|
||||
@@ -150,14 +162,13 @@ namespace MediaBrowser.Server.Implementations.TV
|
||||
|
||||
}).Cast<Episode>().FirstOrDefault();
|
||||
|
||||
if (lastWatchedEpisode != null)
|
||||
if (lastWatchedEpisode != null && firstUnwatchedEpisode != null)
|
||||
{
|
||||
var userData = _userDataManager.GetUserData(user, lastWatchedEpisode);
|
||||
|
||||
if (userData.LastPlayedDate.HasValue)
|
||||
{
|
||||
return new Tuple<Episode, DateTime, bool>(firstUnwatchedEpisode, userData.LastPlayedDate.Value, false);
|
||||
}
|
||||
var lastWatchedDate = userData.LastPlayedDate ?? DateTime.MinValue.AddDays(1);
|
||||
|
||||
return new Tuple<Episode, DateTime, bool>(firstUnwatchedEpisode, lastWatchedDate, false);
|
||||
}
|
||||
|
||||
// Return the first episode
|
||||
|
||||
Reference in New Issue
Block a user