next up upgrade fixes
This commit is contained in:
parent
43bcf7ba1d
commit
0920c9b3a1
|
@ -1655,7 +1655,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
if (datePlayed.HasValue)
|
||||
{
|
||||
// Incremenet
|
||||
// Increment
|
||||
data.PlayCount++;
|
||||
}
|
||||
|
||||
|
@ -1667,7 +1667,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
data.PlaybackPositionTicks = 0;
|
||||
}
|
||||
|
||||
data.LastPlayedDate = datePlayed ?? data.LastPlayedDate;
|
||||
data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow;
|
||||
data.Played = true;
|
||||
|
||||
await UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None).ConfigureAwait(false);
|
||||
|
|
|
@ -111,11 +111,20 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
}
|
||||
}
|
||||
|
||||
private static string GetUniqueSeriesKey(BaseItem series)
|
||||
{
|
||||
if (ConfigurationManager.Configuration.SchemaVersion < 97)
|
||||
{
|
||||
return series.Id.ToString("N");
|
||||
}
|
||||
return series.PresentationUniqueKey;
|
||||
}
|
||||
|
||||
public override int GetChildCount(User user)
|
||||
{
|
||||
var result = LibraryManager.GetItemsResult(new InternalItemsQuery(user)
|
||||
{
|
||||
AncestorWithPresentationUniqueKey = PresentationUniqueKey,
|
||||
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
|
||||
IncludeItemTypes = new[] { typeof(Season).Name },
|
||||
SortBy = new[] { ItemSortBy.SortName },
|
||||
IsVirtualItem = false,
|
||||
|
@ -202,7 +211,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
|
||||
if (query.Recursive)
|
||||
{
|
||||
query.AncestorWithPresentationUniqueKey = PresentationUniqueKey;
|
||||
query.AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this);
|
||||
if (query.SortBy.Length == 0)
|
||||
{
|
||||
query.SortBy = new[] { ItemSortBy.SortName };
|
||||
|
@ -228,7 +237,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
|
||||
seasons = LibraryManager.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
AncestorWithPresentationUniqueKey = PresentationUniqueKey,
|
||||
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
|
||||
IncludeItemTypes = new[] { typeof(Season).Name },
|
||||
SortBy = new[] { ItemSortBy.SortName }
|
||||
|
||||
|
@ -257,7 +266,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
{
|
||||
var allItems = LibraryManager.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
AncestorWithPresentationUniqueKey = PresentationUniqueKey,
|
||||
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
|
||||
IncludeItemTypes = new[] { typeof(Episode).Name, typeof(Season).Name },
|
||||
SortBy = new[] { ItemSortBy.SortName }
|
||||
|
||||
|
@ -354,7 +363,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
{
|
||||
return LibraryManager.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
AncestorWithPresentationUniqueKey = PresentationUniqueKey,
|
||||
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
|
||||
IncludeItemTypes = new[] { typeof(Episode).Name },
|
||||
SortBy = new[] { ItemSortBy.SortName }
|
||||
|
||||
|
@ -423,7 +432,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
public static IEnumerable<Episode> FilterEpisodesBySeason(IEnumerable<Episode> episodes, Season parentSeason, bool includeSpecials)
|
||||
{
|
||||
var seasonNumber = parentSeason.IndexNumber;
|
||||
var seasonPresentationKey = parentSeason.PresentationUniqueKey;
|
||||
var seasonPresentationKey = GetUniqueSeriesKey(parentSeason);
|
||||
|
||||
var supportSpecialsInSeason = includeSpecials && seasonNumber.HasValue && seasonNumber.Value != 0;
|
||||
|
||||
|
@ -443,7 +452,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
if (!episode.ParentIndexNumber.HasValue)
|
||||
{
|
||||
var season = episode.Season;
|
||||
return season != null && string.Equals(season.PresentationUniqueKey, seasonPresentationKey, StringComparison.OrdinalIgnoreCase);
|
||||
return season != null && string.Equals(GetUniqueSeriesKey(season), seasonPresentationKey, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -20,6 +20,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MoreLinq;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
|
@ -1200,7 +1201,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
{
|
||||
var user = query.User;
|
||||
|
||||
items = libraryManager.ReplaceVideosWithPrimaryVersions(items);
|
||||
items = items.DistinctBy(i => i.PresentationUniqueKey, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
if (query.SortBy.Length > 0)
|
||||
{
|
||||
|
|
|
@ -308,13 +308,6 @@ namespace MediaBrowser.Controller.Library
|
|||
/// <returns>Task.</returns>
|
||||
Task DeleteItem(BaseItem item, DeleteOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the videos with primary versions.
|
||||
/// </summary>
|
||||
/// <param name="items">The items.</param>
|
||||
/// <returns>IEnumerable{BaseItem}.</returns>
|
||||
IEnumerable<BaseItem> ReplaceVideosWithPrimaryVersions(IEnumerable<BaseItem> items);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the named view.
|
||||
/// </summary>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -477,7 +477,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||
ImageProcessor = GetImageProcessor();
|
||||
RegisterSingleInstance(ImageProcessor);
|
||||
|
||||
TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager);
|
||||
TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager, ServerConfigurationManager);
|
||||
RegisterSingleInstance(TVSeriesManager);
|
||||
|
||||
SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder, FileSystemManager, () => SubtitleEncoder, ServerConfigurationManager, UserDataManager, () => MediaSourceManager, JsonSerializer, TaskManager);
|
||||
|
|
Loading…
Reference in New Issue
Block a user