mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-09 23:30:50 +02:00
fix next up order
This commit is contained in:
parent
775fc94020
commit
404f2338f9
|
@ -46,6 +46,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
public string NameStartsWith { get; set; }
|
public string NameStartsWith { get; set; }
|
||||||
public string NameLessThan { get; set; }
|
public string NameLessThan { get; set; }
|
||||||
public string NameContains { get; set; }
|
public string NameContains { get; set; }
|
||||||
|
public string MinSortName { get; set; }
|
||||||
|
|
||||||
public string PresentationUniqueKey { get; set; }
|
public string PresentationUniqueKey { get; set; }
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
|
|
@ -2663,6 +2663,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
cmd.Parameters.Add(cmd, "@SlugName", DbType.String).Value = query.SlugName;
|
cmd.Parameters.Add(cmd, "@SlugName", DbType.String).Value = query.SlugName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(query.MinSortName))
|
||||||
|
{
|
||||||
|
whereClauses.Add("SortName>=@MinSortName");
|
||||||
|
cmd.Parameters.Add(cmd, "@MinSortName", DbType.String).Value = query.MinSortName;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(query.Name))
|
if (!string.IsNullOrWhiteSpace(query.Name))
|
||||||
{
|
{
|
||||||
whereClauses.Add("CleanName=@Name");
|
whereClauses.Add("CleanName=@Name");
|
||||||
|
@ -3773,7 +3779,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
whereText += " And itemTypes not null";
|
//whereText += " And itemTypes not null";
|
||||||
|
whereText += " And CleanName In (Select CleanValue from ItemValues where Type=@ItemValueType AND ItemId in (select guid from TypedBaseItems" + innerWhereText + "))";
|
||||||
}
|
}
|
||||||
|
|
||||||
var outerQuery = new InternalItemsQuery(query.User)
|
var outerQuery = new InternalItemsQuery(query.User)
|
||||||
|
@ -3855,7 +3862,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
? (CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)
|
? (CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)
|
||||||
: CommandBehavior.SequentialAccess;
|
: CommandBehavior.SequentialAccess;
|
||||||
|
|
||||||
//Logger.Debug("GetItemValues: " + cmd.CommandText);
|
Logger.Debug("GetItemValues: " + cmd.CommandText);
|
||||||
|
|
||||||
using (var reader = cmd.ExecuteReader(commandBehavior))
|
using (var reader = cmd.ExecuteReader(commandBehavior))
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,7 +107,6 @@ namespace MediaBrowser.Server.Implementations.TV
|
||||||
var currentUser = user;
|
var currentUser = user;
|
||||||
|
|
||||||
return series
|
return series
|
||||||
.AsParallel()
|
|
||||||
.Select(i => GetNextUp(i, currentUser))
|
.Select(i => GetNextUp(i, currentUser))
|
||||||
// Include if an episode was found, and either the series is not unwatched or the specific series was requested
|
// Include if an episode was found, and either the series is not unwatched or the specific series was requested
|
||||||
.Where(i => i.Item1 != null && (!i.Item3 || !string.IsNullOrWhiteSpace(request.SeriesId)))
|
.Where(i => i.Item1 != null && (!i.Item3 || !string.IsNullOrWhiteSpace(request.SeriesId)))
|
||||||
|
@ -124,6 +123,19 @@ namespace MediaBrowser.Server.Implementations.TV
|
||||||
/// <returns>Task{Episode}.</returns>
|
/// <returns>Task{Episode}.</returns>
|
||||||
private Tuple<Episode, DateTime, bool> GetNextUp(Series series, User user)
|
private Tuple<Episode, DateTime, bool> GetNextUp(Series series, User user)
|
||||||
{
|
{
|
||||||
|
var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||||
|
{
|
||||||
|
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
|
||||||
|
IncludeItemTypes = new[] { typeof(Episode).Name },
|
||||||
|
SortBy = new[] { ItemSortBy.SortName },
|
||||||
|
SortOrder = SortOrder.Descending,
|
||||||
|
IsPlayed = true,
|
||||||
|
Limit = 1,
|
||||||
|
IsVirtualItem = false,
|
||||||
|
ParentIndexNumberNotEquals = 0
|
||||||
|
|
||||||
|
}).FirstOrDefault();
|
||||||
|
|
||||||
var firstUnwatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
var firstUnwatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||||
{
|
{
|
||||||
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
|
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
|
||||||
|
@ -133,59 +145,11 @@ namespace MediaBrowser.Server.Implementations.TV
|
||||||
Limit = 1,
|
Limit = 1,
|
||||||
IsPlayed = false,
|
IsPlayed = false,
|
||||||
IsVirtualItem = false,
|
IsVirtualItem = false,
|
||||||
ParentIndexNumberNotEquals = 0
|
ParentIndexNumberNotEquals = 0,
|
||||||
|
MinSortName = lastWatchedEpisode == null ? null : lastWatchedEpisode.SortName
|
||||||
|
|
||||||
}).Cast<Episode>().FirstOrDefault();
|
}).Cast<Episode>().FirstOrDefault();
|
||||||
|
|
||||||
// series is fully played
|
|
||||||
if (firstUnwatchedEpisode == null)
|
|
||||||
{
|
|
||||||
return new Tuple<Episode, DateTime, bool>(null, DateTime.MinValue, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
|
||||||
{
|
|
||||||
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
|
|
||||||
IncludeItemTypes = new[] { typeof(Episode).Name },
|
|
||||||
SortBy = new[] { ItemSortBy.DatePlayed },
|
|
||||||
SortOrder = SortOrder.Descending,
|
|
||||||
Limit = 1,
|
|
||||||
IsVirtualItem = false,
|
|
||||||
ParentIndexNumberNotEquals = 0
|
|
||||||
|
|
||||||
}).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)
|
if (lastWatchedEpisode != null)
|
||||||
{
|
{
|
||||||
var userData = _userDataManager.GetUserData(user, lastWatchedEpisode);
|
var userData = _userDataManager.GetUserData(user, lastWatchedEpisode);
|
||||||
|
|
Loading…
Reference in a new issue