aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWizardOfYendor1 <WizardOfYendor1@users.noreply.github.com>2026-07-11 10:12:42 -0400
committerWizardOfYendor1 <WizardOfYendor1@users.noreply.github.com>2026-07-11 10:12:42 -0400
commit6f189bf2b81c7ddc80b8f9ad7740df752903cd14 (patch)
tree64bfee3824fb6720a977198fb4e98ba9d3933140
parentf3ff7a446b613c0cd7b83e36a7f2e385f5301e15 (diff)
Reduce GetPlaybackInfo cognitive complexity
-rw-r--r--Jellyfin.Api/Helpers/MediaInfoHelper.cs46
1 files changed, 23 insertions, 23 deletions
diff --git a/Jellyfin.Api/Helpers/MediaInfoHelper.cs b/Jellyfin.Api/Helpers/MediaInfoHelper.cs
index f178a79999..31e907549c 100644
--- a/Jellyfin.Api/Helpers/MediaInfoHelper.cs
+++ b/Jellyfin.Api/Helpers/MediaInfoHelper.cs
@@ -99,29 +99,7 @@ public class MediaInfoHelper
{
var result = new PlaybackInfoResponse();
- MediaSourceInfo[] mediaSources;
- if (string.IsNullOrWhiteSpace(liveStreamId))
- {
- // TODO (moved from MediaBrowser.Api) handle supportedLiveMediaTypes?
- var mediaSourcesList = await _mediaSourceManager.GetPlaybackMediaSources(item, user, true, true, CancellationToken.None).ConfigureAwait(false);
-
- if (string.IsNullOrWhiteSpace(mediaSourceId))
- {
- mediaSources = mediaSourcesList.ToArray();
- }
- else
- {
- mediaSources = mediaSourcesList
- .Where(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase))
- .ToArray();
- }
- }
- else
- {
- var mediaSource = await _mediaSourceManager.GetLiveStream(liveStreamId, CancellationToken.None).ConfigureAwait(false);
-
- mediaSources = new[] { mediaSource };
- }
+ var mediaSources = await ResolvePlaybackMediaSources(item, user, mediaSourceId, liveStreamId).ConfigureAwait(false);
if (mediaSources.Length == 0)
{
@@ -157,6 +135,28 @@ public class MediaInfoHelper
return result;
}
+ private async Task<MediaSourceInfo[]> ResolvePlaybackMediaSources(BaseItem item, User? user, string? mediaSourceId, string? liveStreamId)
+ {
+ if (!string.IsNullOrWhiteSpace(liveStreamId))
+ {
+ var mediaSource = await _mediaSourceManager.GetLiveStream(liveStreamId, CancellationToken.None).ConfigureAwait(false);
+
+ return new[] { mediaSource };
+ }
+
+ // TODO (moved from MediaBrowser.Api) handle supportedLiveMediaTypes?
+ var mediaSourcesList = await _mediaSourceManager.GetPlaybackMediaSources(item, user, true, true, CancellationToken.None).ConfigureAwait(false);
+
+ if (string.IsNullOrWhiteSpace(mediaSourceId))
+ {
+ return mediaSourcesList.ToArray();
+ }
+
+ return mediaSourcesList
+ .Where(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase))
+ .ToArray();
+ }
+
/// <summary>
/// SetDeviceSpecificData.
/// </summary>