From a0bef3568b81db49a85d7f0c8bfc758239b71825 Mon Sep 17 00:00:00 2001
From: Jason Dove <1695733+jasongdove@users.noreply.github.com>
Date: Sat, 16 Nov 2024 19:28:30 -0600
Subject: [PATCH] fix selecting audio stream with preferred title (#1937)
* update dependencies to fix build errors
* fix selecting audio stream with preferred title
---
CHANGELOG.md | 1 +
.../ErsatzTV.Application.csproj | 2 +-
.../ErsatzTV.Core.Tests.csproj | 2 +-
.../FFmpeg/FFmpegStreamSelectorTests.cs | 55 +++++++++++++++++++
ErsatzTV.Core/ErsatzTV.Core.csproj | 11 ++--
ErsatzTV.Core/FFmpeg/FFmpegStreamSelector.cs | 2 +-
.../ErsatzTV.Infrastructure.Tests.csproj | 2 +-
.../ErsatzTV.Infrastructure.csproj | 11 ++--
.../ErsatzTV.Scanner.Tests.csproj | 2 +-
ErsatzTV.sln | 4 +-
ErsatzTV/ErsatzTV.csproj | 17 ++++--
11 files changed, 87 insertions(+), 22 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d5256f20..3047a97f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Now, content will properly scale beyond the desired resolution before cropping
- Fix displaying playout item durations that are greater than 24 hours
- Fix building playouts when playlist has been changed to have fewer items
+- Fix selecting audio stream with preferred title
## [0.8.8-beta] - 2024-09-19
### Added
diff --git a/ErsatzTV.Application/ErsatzTV.Application.csproj b/ErsatzTV.Application/ErsatzTV.Application.csproj
index 9121cd96..4db82ed0 100644
--- a/ErsatzTV.Application/ErsatzTV.Application.csproj
+++ b/ErsatzTV.Application/ErsatzTV.Application.csproj
@@ -15,7 +15,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj b/ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj
index a5112284..2a7fc214 100644
--- a/ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj
+++ b/ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj
@@ -17,7 +17,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/ErsatzTV.Core.Tests/FFmpeg/FFmpegStreamSelectorTests.cs b/ErsatzTV.Core.Tests/FFmpeg/FFmpegStreamSelectorTests.cs
index 00efce01..bbd3095c 100644
--- a/ErsatzTV.Core.Tests/FFmpeg/FFmpegStreamSelectorTests.cs
+++ b/ErsatzTV.Core.Tests/FFmpeg/FFmpegStreamSelectorTests.cs
@@ -71,6 +71,61 @@ public class FFmpegStreamSelectorTests
}
}
+ [Test]
+ public async Task Should_Select_Audio_Stream_With_Preferred_Title()
+ {
+ // skip movie/episode script paths by using other video
+ var mediaItem = new OtherVideo();
+ var mediaVersion = new MediaVersion
+ {
+ Streams =
+ [
+ new MediaStream
+ {
+ Index = 0,
+ MediaStreamKind = MediaStreamKind.Audio,
+ Channels = 2,
+ Language = "ja",
+ Title = "Some Title",
+ },
+ new MediaStream
+ {
+ Index = 1,
+ MediaStreamKind = MediaStreamKind.Audio,
+ Channels = 6,
+ Language = "eng",
+ Title = "Another Title",
+ Default = true
+ }
+ ]
+ };
+
+ var audioVersion = new MediaItemAudioVersion(mediaItem, mediaVersion);
+ var channel = new Channel(Guid.NewGuid())
+ {
+ PreferredAudioTitle = "Some"
+ };
+
+ ISearchRepository searchRepository = Substitute.For();
+ searchRepository.GetAllThreeLetterLanguageCodes(Arg.Any>())
+ .Returns(Task.FromResult(new List { "jpn", "eng" }));
+
+ var selector = new FFmpegStreamSelector(
+ new ScriptEngine(Substitute.For>()),
+ Substitute.For(),
+ searchRepository,
+ Substitute.For(),
+ Substitute.For(),
+ Substitute.For>());
+
+ Option selectedStream = await selector.SelectAudioStream(audioVersion, StreamingMode.TransportStream, channel, null, channel.PreferredAudioTitle);
+ selectedStream.IsSome.Should().BeTrue();
+ foreach (MediaStream stream in selectedStream)
+ {
+ stream.Language.Should().Be("ja");
+ }
+ }
+
[Test]
public async Task Should_Select_Subtitle_Stream_With_Preferred_Language()
{
diff --git a/ErsatzTV.Core/ErsatzTV.Core.csproj b/ErsatzTV.Core/ErsatzTV.Core.csproj
index 91c7c126..1407cf1c 100644
--- a/ErsatzTV.Core/ErsatzTV.Core.csproj
+++ b/ErsatzTV.Core/ErsatzTV.Core.csproj
@@ -20,7 +20,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -30,15 +30,18 @@
-
+
+
+
+
-
+
<_Parameter1>ErsatzTV.Core.Tests
-
+
diff --git a/ErsatzTV.Core/FFmpeg/FFmpegStreamSelector.cs b/ErsatzTV.Core/FFmpeg/FFmpegStreamSelector.cs
index 3624ac78..49c87dd5 100644
--- a/ErsatzTV.Core/FFmpeg/FFmpegStreamSelector.cs
+++ b/ErsatzTV.Core/FFmpeg/FFmpegStreamSelector.cs
@@ -275,7 +275,7 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
matchingTitle.Count,
title);
- return PrioritizeDefault(streams);
+ return PrioritizeDefault(matchingTitle);
}
_logger.LogDebug("Unable to find audio stream with preferred title {Title}", title);
diff --git a/ErsatzTV.Infrastructure.Tests/ErsatzTV.Infrastructure.Tests.csproj b/ErsatzTV.Infrastructure.Tests/ErsatzTV.Infrastructure.Tests.csproj
index 24431ead..67c2c392 100644
--- a/ErsatzTV.Infrastructure.Tests/ErsatzTV.Infrastructure.Tests.csproj
+++ b/ErsatzTV.Infrastructure.Tests/ErsatzTV.Infrastructure.Tests.csproj
@@ -14,7 +14,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/ErsatzTV.Infrastructure/ErsatzTV.Infrastructure.csproj b/ErsatzTV.Infrastructure/ErsatzTV.Infrastructure.csproj
index 61085c8e..7b66f646 100644
--- a/ErsatzTV.Infrastructure/ErsatzTV.Infrastructure.csproj
+++ b/ErsatzTV.Infrastructure/ErsatzTV.Infrastructure.csproj
@@ -24,22 +24,23 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
+
+
+
+
-
-
-
diff --git a/ErsatzTV.Scanner.Tests/ErsatzTV.Scanner.Tests.csproj b/ErsatzTV.Scanner.Tests/ErsatzTV.Scanner.Tests.csproj
index ff47741e..aeeaeac0 100644
--- a/ErsatzTV.Scanner.Tests/ErsatzTV.Scanner.Tests.csproj
+++ b/ErsatzTV.Scanner.Tests/ErsatzTV.Scanner.Tests.csproj
@@ -15,7 +15,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/ErsatzTV.sln b/ErsatzTV.sln
index 59e7c047..3349e3ac 100644
--- a/ErsatzTV.sln
+++ b/ErsatzTV.sln
@@ -37,8 +37,8 @@ Global
{E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Release|Any CPU.Build.0 = Release|Any CPU
{E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug No Sync|Any CPU.ActiveCfg = Debug No Sync|Any CPU
- {E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug No Sync|Any CPU.Build.0 = Debug No Sync|Any CPU
+ {E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug No Sync|Any CPU.ActiveCfg = Debug|Any CPU
+ {E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug No Sync|Any CPU.Build.0 = Debug|Any CPU
{C56FC23D-B863-401E-8E7C-E92BC307AFC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C56FC23D-B863-401E-8E7C-E92BC307AFC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C56FC23D-B863-401E-8E7C-E92BC307AFC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/ErsatzTV/ErsatzTV.csproj b/ErsatzTV/ErsatzTV.csproj
index 6dd39a3e..4830c526 100644
--- a/ErsatzTV/ErsatzTV.csproj
+++ b/ErsatzTV/ErsatzTV.csproj
@@ -18,22 +18,22 @@
-
+
-
-
-
-
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -47,6 +47,11 @@
+
+
+
+
+