TV Series playback from episode list does not require mediaSourceId
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-04-13 20:55:02 +00:00
parent 544aa28dc0
commit ecf47354e6
2 changed files with 24 additions and 19 deletions

View File

@@ -247,25 +247,28 @@ sealed class CinemaMediaSourceManager : IMediaSourceManager
// We need to directly inspect the video file and therefore need to know which
// version to specifically return. For free accounts it is not possible to just
// read files at random, for VIP accounts that would slow playback startup also.
Guid mediaSourceId;
if (ctx == null
|| !ctx.Items.TryGetValue(ContextItemsMediaSourceIdKey, out object? mediaSourceIdO)
|| mediaSourceIdO is not string mediaSourceIdS
|| (!Guid.TryParse(mediaSourceIdS, out mediaSourceId)))
throw new InvalidOperationException("For precise stream indexing knowing mediaSourceId is required.");
// Warning: We assume GetVideoVersionsEnumerate keeps the order between its input and output collections
int idxVer = 0;
Video? videoVer = null;
foreach (Video i in items)
if ((!sortByPrefs && i.Id == mediaSourceId)
|| (sortByPrefs && idxVer == bestIdx))
{
videoVer = i;
break;
}
else
idxVer++;
Video? videoVer;
int idxVer;
if (!sortByPrefs) {
Guid mediaSourceId;
if (ctx == null
|| !ctx.Items.TryGetValue(ContextItemsMediaSourceIdKey, out object? mediaSourceIdO)
|| mediaSourceIdO is not string mediaSourceIdS
|| (!Guid.TryParse(mediaSourceIdS, out mediaSourceId)))
throw new InvalidOperationException("For precise stream indexing knowing mediaSourceId is required.");
idxVer = -1;
videoVer = items.Where((x, idx) => {
bool isMatch = x.Id == mediaSourceId;
if (isMatch)
idxVer = idx;
return isMatch;
}).FirstOrDefault();
} else {
idxVer = bestIdx;
videoVer = items.Skip(bestIdx).FirstOrDefault();
}
if (videoVer == null)
// Version not found, return empty set
break;

View File

@@ -104,7 +104,9 @@ public class CinemaServiceRegistrator : IPluginServiceRegistrator
// Fallback to the obsolete query argument
if (!context.ActionArguments.TryGetValue("mediaSourceId", out object? mediaSourceIdO)
|| (mediaSourceId = mediaSourceIdO as string) == null)
throw new InvalidOperationException("Cannot extract MediaSourceId from the Jellyfin's action MediaInfo.GetPostedPlaybackInfo.");
// It is optional in certain situations
return;
//throw new InvalidOperationException("Cannot extract MediaSourceId from the Jellyfin's action MediaInfo.GetPostedPlaybackInfo.");
}
context.HttpContext.Items.Add(CinemaMediaSourceManager.ContextItemsMediaSourceIdKey, mediaSourceId);