Fixed: Handle 3 digit audio channels

This commit is contained in:
Qstick 2019-12-24 01:24:47 -05:00 committed by Mark McDowall
parent 7b04e11c54
commit 314a12ffb5
1 changed files with 27 additions and 3 deletions

View File

@ -458,13 +458,37 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
if (audioChannelPositions.Contains("/")) if (audioChannelPositions.Contains("/"))
{ {
return Regex.Replace(audioChannelPositions, @"^\d+\sobjects", "", var channelStringList = Regex.Replace(audioChannelPositions,
@"^\d+\sobjects",
"",
RegexOptions.Compiled | RegexOptions.IgnoreCase) RegexOptions.Compiled | RegexOptions.IgnoreCase)
.Replace("Object Based / ", "") .Replace("Object Based / ", "")
.Split(new string[] {" / "}, StringSplitOptions.RemoveEmptyEntries) .Split(new string[] {" / "}, StringSplitOptions.RemoveEmptyEntries)
.FirstOrDefault() .FirstOrDefault()
?.Split('/') ?.Split('/');
.Sum(s => decimal.Parse(s, CultureInfo.InvariantCulture));
var positions = default(decimal);
if (channelStringList == null)
{
return 0;
}
foreach (var channel in channelStringList)
{
var channelSplit = channel.Split(new string[] { "." }, StringSplitOptions.None);
if (channelSplit.Count() == 3)
{
positions += decimal.Parse(string.Format("{0}.{1}", channelSplit[1], channelSplit[2]));
}
else
{
positions += decimal.Parse(channel);
}
}
return positions;
} }
} }
catch (Exception e) catch (Exception e)