From 3a95d4b04ebb5aa612b0d175261fbe473a0e60fa Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Sun, 29 May 2022 08:49:36 -0600 Subject: [PATCH] Merge pull request #7802 from jellyfin/external (cherry picked from commit 9954cbd550cc0b85ae6579e2504372f74316e7b8) Signed-off-by: crobibero --- .../MediaInfo/MediaInfoResolver.cs | 28 ++++++++++--------- .../MediaInfo/AudioResolverTests.cs | 3 ++ .../MediaInfo/MediaInfoResolverTests.cs | 5 +++- .../MediaInfo/SubtitleResolverTests.cs | 3 ++ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs b/MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs index 1421d0183d..6d9aac2c0f 100644 --- a/MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs +++ b/MediaBrowser.Providers/MediaInfo/MediaInfoResolver.cs @@ -106,19 +106,28 @@ namespace MediaBrowser.Providers.MediaInfo if (mediaInfo.MediaStreams.Count == 1) { MediaStream mediaStream = mediaInfo.MediaStreams[0]; - mediaStream.Index = startIndex++; - mediaStream.IsDefault = pathInfo.IsDefault || mediaStream.IsDefault; - mediaStream.IsForced = pathInfo.IsForced || mediaStream.IsForced; - mediaStreams.Add(MergeMetadata(mediaStream, pathInfo)); + if ((mediaStream.Type == MediaStreamType.Audio && _type == DlnaProfileType.Audio) + || (mediaStream.Type == MediaStreamType.Subtitle && _type == DlnaProfileType.Subtitle)) + { + mediaStream.Index = startIndex++; + mediaStream.IsDefault = pathInfo.IsDefault || mediaStream.IsDefault; + mediaStream.IsForced = pathInfo.IsForced || mediaStream.IsForced; + + mediaStreams.Add(MergeMetadata(mediaStream, pathInfo)); + } } else { foreach (MediaStream mediaStream in mediaInfo.MediaStreams) { - mediaStream.Index = startIndex++; + if ((mediaStream.Type == MediaStreamType.Audio && _type == DlnaProfileType.Audio) + || (mediaStream.Type == MediaStreamType.Subtitle && _type == DlnaProfileType.Subtitle)) + { + mediaStream.Index = startIndex++; - mediaStreams.Add(MergeMetadata(mediaStream, pathInfo)); + mediaStreams.Add(MergeMetadata(mediaStream, pathInfo)); + } } } } @@ -222,13 +231,6 @@ namespace MediaBrowser.Providers.MediaInfo mediaStream.Title = string.IsNullOrEmpty(mediaStream.Title) ? (string.IsNullOrEmpty(pathInfo.Title) ? null : pathInfo.Title) : mediaStream.Title; mediaStream.Language = string.IsNullOrEmpty(mediaStream.Language) ? (string.IsNullOrEmpty(pathInfo.Language) ? null : pathInfo.Language) : mediaStream.Language; - mediaStream.Type = _type switch - { - DlnaProfileType.Audio => MediaStreamType.Audio, - DlnaProfileType.Subtitle => MediaStreamType.Subtitle, - _ => mediaStream.Type - }; - return mediaStream; } } diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/AudioResolverTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/AudioResolverTests.cs index aec523882d..9296892094 100644 --- a/tests/Jellyfin.Providers.Tests/MediaInfo/AudioResolverTests.cs +++ b/tests/Jellyfin.Providers.Tests/MediaInfo/AudioResolverTests.cs @@ -43,6 +43,9 @@ public class AudioResolverTests MediaStreams = new List { new() + { + Type = MediaStreamType.Audio + } } })); diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs index 98b4a6ccf6..7c3027f949 100644 --- a/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs +++ b/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs @@ -359,7 +359,10 @@ public class MediaInfoResolverTests var mediaStreams = new List(); for (int i = 0; i < streamCount; i++) { - mediaStreams.Add(new()); + mediaStreams.Add(new() + { + Type = MediaStreamType.Subtitle + }); } return mediaStreams; diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/SubtitleResolverTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/SubtitleResolverTests.cs index 0e6457ce37..6de6d296e5 100644 --- a/tests/Jellyfin.Providers.Tests/MediaInfo/SubtitleResolverTests.cs +++ b/tests/Jellyfin.Providers.Tests/MediaInfo/SubtitleResolverTests.cs @@ -43,6 +43,9 @@ public class SubtitleResolverTests MediaStreams = new List { new() + { + Type = MediaStreamType.Subtitle + } } }));