From be6812056838732b597594bfb6d6eba4f0bee55b Mon Sep 17 00:00:00 2001 From: zotabee <89345101+zotabee@users.noreply.github.com> Date: Sat, 17 Oct 2026 15:26:12 +0200 Subject: [PATCH] Fall back to the channel count for unknown audio layouts Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0181seTYh8Bo6yc19Ba5p5bo --- Trakt/Extensions.cs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Trakt/Extensions.cs b/Trakt/Extensions.cs index c48f348c..a1c31640 100644 --- a/Trakt/Extensions.cs +++ b/Trakt/Extensions.cs @@ -294,13 +294,12 @@ public static int GetSeasonNumber(this Episode episode) /// string. public static string GetAudioChannels(this MediaStream audioStream) { - if (audioStream == null || string.IsNullOrEmpty(audioStream.ChannelLayout)) + if (audioStream == null) { return null; } - var channels = audioStream.ChannelLayout; - switch (channels) + switch (audioStream.ChannelLayout) { case "22.2": case "hexadecagonal": @@ -357,10 +356,30 @@ public static string GetAudioChannels(this MediaStream audioStream) case "mono": return "1.0"; default: - return null; + // Missing or unknown layout, e.g. "6 channels" + return GetAudioChannelsFromCount(audioStream.Channels); } } + /// + /// Gets the most common trakt.tv audio channels value for a channel count. + /// + /// The number of audio channels. + /// string. + private static string GetAudioChannelsFromCount(int? channelCount) + => channelCount switch + { + 1 => "1.0", + 2 => "2.0", + 3 => "2.1", + 4 => "4.0", + 5 => "5.0", + 6 => "5.1", + 7 => "6.1", + 8 => "7.1", + _ => null + }; + /// /// Gets a watched match for a series. ///