fix: improve bitrate fetching for media files

Added a check for tags that start with "BPS" to retrieve the first occurrence of a bitrate value. This check uses the FirstOrDefault method to find tags where the key starts with "BPS", considering it may vary for different languages (e.g., BPS-jpn). While I have encountered only BPS-eng so far, this approach is flexible enough to handle other variations in the future.

However, if this method is deemed unstable, it could be hardcoded to specifically match BPS-eng instead.

Why this update might be helpful:
Fixes missing bitrate information on the Media Info popover in the web UI, for both audio and video streams. I have found that the BPS-eng tag is relatively common on anime specifically, which is consequently often missing bitrate information.
pull/7670/head
Ender 2 months ago committed by GitHub
parent 950330b091
commit 615a086320
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -173,6 +173,13 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
return Convert.ToInt64(bitratePerSecond);
}
// Check for keys that start with BPS as some files contain the BPS-eng tag
if (mediaStream?.Tags?.FirstOrDefault(kvp => kvp.Key.StartsWith("BPS", StringComparison.OrdinalIgnoreCase)).Value?.IsNotNullOrWhiteSpace() ?? false)
{
bitratePerSecond = mediaStream.Tags.FirstOrDefault(kvp => kvp.Key.StartsWith("BPS", StringComparison.OrdinalIgnoreCase)).Value;
return Convert.ToInt64(bitratePerSecond);
}
return 0;
}

Loading…
Cancel
Save