Resume play seems still broken with mixed local/cinema content
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -272,8 +272,8 @@ sealed class CinemaLibraryManager : ILibraryManager
|
||||
// Not a search at the root so do not involve our root folders
|
||||
return result;
|
||||
|
||||
List<BaseItem> resultL = new List<BaseItem>(result.Items);
|
||||
|
||||
List<BaseItem> resultL = new List<BaseItem>();
|
||||
HashSet<Guid> innerAdded = new HashSet<Guid>();
|
||||
if (query.OrderBy.FirstOrDefault().OrderBy == ItemSortBy.DatePlayed && query.User != null && query.MediaTypes.Contains(MediaType.Video))
|
||||
{
|
||||
// Get Resume play items
|
||||
@@ -282,17 +282,42 @@ sealed class CinemaLibraryManager : ILibraryManager
|
||||
.OrderByDescending(x => x.Played)
|
||||
.Skip(query.StartIndex ?? 0)
|
||||
.Take(query.Limit ?? 20);
|
||||
foreach (var i in resumePlay)
|
||||
foreach (UserItemData i in resumePlay)
|
||||
{
|
||||
// Note: All Cinema items override GetUserDataKeys and return ExternalId
|
||||
string? csId;
|
||||
if (!CinemaQueryExtensions.TryGetCinemaIdFromExternalId(i.Key, out csId))
|
||||
continue;
|
||||
|
||||
if (CinemaQueryExtensions.TryGetCinemaIdFromExternalId(i.Key, out csId))
|
||||
{
|
||||
// First try to get already in-memory item
|
||||
Guid itemId = CinemaQueryExtensions.GetMediaItemId(csId, null);
|
||||
BaseItem? item = _inner.GetItemById(itemId);
|
||||
if (item == null)
|
||||
{
|
||||
// Fetch it from cinema
|
||||
MediaSource? ms = Metadata.DetailAsync(csId, default).GetAwaiter().GetResult();
|
||||
if (CinemaQueryExtensions.TryCreateMediaItem<Folder>(ms, csId, null, false, out BaseItem? a))
|
||||
resultL.Add(a);
|
||||
CinemaQueryExtensions.TryCreateMediaItem<Folder>(ms, csId, null, false, out item);
|
||||
}
|
||||
if (item != null)
|
||||
resultL.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try to append item from the inner result
|
||||
if (Guid.TryParse(i.Key, out Guid key))
|
||||
foreach (BaseItem j in result.Items)
|
||||
if (j.Id == key)
|
||||
{
|
||||
resultL.Add(j);
|
||||
innerAdded.Add(key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Append the not-seen inner items
|
||||
foreach (BaseItem i in result.Items)
|
||||
if (!innerAdded.Contains(i.Id))
|
||||
resultL.Add(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user