diff --git a/ErsatzTV.Infrastructure.Tests/Metadata/LocalStatisticsProviderTests.cs b/ErsatzTV.Infrastructure.Tests/Metadata/LocalStatisticsProviderTests.cs index f41a637b0..9a0e78ef2 100644 --- a/ErsatzTV.Infrastructure.Tests/Metadata/LocalStatisticsProviderTests.cs +++ b/ErsatzTV.Infrastructure.Tests/Metadata/LocalStatisticsProviderTests.cs @@ -37,9 +37,10 @@ public class LocalStatisticsProviderTests string.Empty, string.Empty, string.Empty, + string.Empty, string.Empty)), - new List(), - new List()); + [], + []); MediaVersion result = provider.ProjectToMediaVersion("test", input); diff --git a/ErsatzTV.Infrastructure/Metadata/LocalStatisticsProvider.cs b/ErsatzTV.Infrastructure/Metadata/LocalStatisticsProvider.cs index 608a597e4..d36e949d1 100644 --- a/ErsatzTV.Infrastructure/Metadata/LocalStatisticsProvider.cs +++ b/ErsatzTV.Infrastructure/Metadata/LocalStatisticsProvider.cs @@ -337,7 +337,7 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider FFprobeStreamData videoStream = json.streams? .Where(s => s.codec_type == "video") - .OrderByDescending(s => ParseBitRate(s.bit_rate)) + .OrderByDescending(ParseBitRate) .FirstOrDefault(); if (videoStream != null) { @@ -497,13 +497,21 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider return Task.FromResult(path); } - private static long ParseBitRate(string bitRate) + private static long ParseBitRate(FFprobeStreamData stream) { - if (long.TryParse(bitRate, out long result)) + if (long.TryParse(stream.bit_rate, out long result)) { return result; } + if (stream.tags?.variantBitrate is not null) + { + if (long.TryParse(stream.tags.variantBitrate, out result)) + { + return result; + } + } + return 0; } @@ -556,9 +564,11 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider string album, string track, string genre, - string date) + string date, + [property: JsonProperty(PropertyName = "variant_bitrate")] + string variantBitrate) { - public static readonly FFprobeTags Empty = new(null, null, null, null, null, null, null, null, null, null); + public static readonly FFprobeTags Empty = new(null, null, null, null, null, null, null, null, null, null, null); } // ReSharper restore InconsistentNaming }