Fixed: Incorrect parsing of APE and OPUS in some cases

Fixes #847
pull/851/head
Qstick 6 years ago
parent 9a240727ed
commit 6dd8df43ca

@ -153,16 +153,9 @@ namespace NzbDrone.Core.Test.ParserTests
ParseAndVerifyQuality(title, desc, bitrate, Quality.APE); ParseAndVerifyQuality(title, desc, bitrate, Quality.APE);
} }
[TestCase("Max Roach - Drums Unlimited (1966) [WavPack]", null, 0)]
[TestCase("Roxette - Charm School(2011) (2CD) [WV]", null, 0)]
[TestCase("", "WavPack", 0)]
public void should_parse_wavpack_quality(string title, string desc, int bitrate)
{
ParseAndVerifyQuality(title, desc, bitrate, Quality.WAVPACK);
}
[TestCase("Arctic Monkeys - AM {2013-Album}", null, 0)] [TestCase("Arctic Monkeys - AM {2013-Album}", null, 0)]
[TestCase("Audio Adrinaline - Audio Adrinaline", null, 0)] [TestCase("Audio Adrinaline - Audio Adrinaline", null, 0)]
[TestCase("Audio Adrinaline - Audio Adrinaline [Mixtape FLAC]", null, 0)]
[TestCase("Brain Ape - Rig it [2014][flac]", null, 0)] [TestCase("Brain Ape - Rig it [2014][flac]", null, 0)]
[TestCase("Coil - The Ape Of Naples(2005) (FLAC)", null, 0)] [TestCase("Coil - The Ape Of Naples(2005) (FLAC)", null, 0)]
public void should_not_parse_ape_quality(string title, string desc, int bitrate) public void should_not_parse_ape_quality(string title, string desc, int bitrate)
@ -171,6 +164,21 @@ namespace NzbDrone.Core.Test.ParserTests
result.Quality.Should().NotBe(Quality.APE); result.Quality.Should().NotBe(Quality.APE);
} }
[TestCase("Opus - Drums Unlimited (1966) [Flac]", null, 0)]
public void should_not_parse_opus_quality(string title, string desc, int bitrate)
{
var result = QualityParser.ParseQuality(title, desc, bitrate);
result.Quality.Should().Be(Quality.FLAC);
}
[TestCase("Max Roach - Drums Unlimited (1966) [WavPack]", null, 0)]
[TestCase("Roxette - Charm School(2011) (2CD) [WV]", null, 0)]
[TestCase("", "WavPack", 0)]
public void should_parse_wavpack_quality(string title, string desc, int bitrate)
{
ParseAndVerifyQuality(title, desc, bitrate, Quality.WAVPACK);
}
[TestCase("Milky Chance - Sadnecessary [256 Kbps] [M4A]", null, 0)] [TestCase("Milky Chance - Sadnecessary [256 Kbps] [M4A]", null, 0)]
[TestCase("Little Mix - Salute [Deluxe Edition] [2013] [M4A-256]-V3nom [GLT", null, 0)] [TestCase("Little Mix - Salute [Deluxe Edition] [2013] [M4A-256]-V3nom [GLT", null, 0)]
[TestCase("X-Men Soundtracks (2006-2014) AAC, 256 kbps", null, 0)] [TestCase("X-Men Soundtracks (2006-2014) AAC, 256 kbps", null, 0)]

@ -36,7 +36,7 @@ namespace NzbDrone.Core.Parser
private static readonly Regex SampleSizeRegex = new Regex(@"\b(?:(?<S24>24[ ]bit|24bit|[\[\(].*24bit.*[\]\)]))"); private static readonly Regex SampleSizeRegex = new Regex(@"\b(?:(?<S24>24[ ]bit|24bit|[\[\(].*24bit.*[\]\)]))");
private static readonly Regex CodecRegex = new Regex(@"\b(?:(?<MP1>MPEG Version \d(.5)? Audio, Layer 1|MP1)|(?<MP2>MPEG Version \d(.5)? Audio, Layer 2|MP2)|(?<MP3VBR>MP3.*VBR|MPEG Version \d(.5)? Audio, Layer 3 vbr)|(?<MP3CBR>MP3|MPEG Version \d(.5)? Audio, Layer 3)|(?<FLAC>flac)|(?<WAVPACK>wavpack|wv)|(?<ALAC>alac)|(?<WMA>WMA\d?)|(?<WAV>WAV|PCM)|(?<AAC>M4A|M4P|M4B|AAC|mp4a|MPEG-4 Audio(?!.*alac))|(?<OGG>OGG|OGA|Vorbis))\b|(?<APE>monkey's audio|[\[|\(].*ape.*[\]|\)])|(?<OPUS>Opus)", private static readonly Regex CodecRegex = new Regex(@"\b(?:(?<MP1>MPEG Version \d(.5)? Audio, Layer 1|MP1)|(?<MP2>MPEG Version \d(.5)? Audio, Layer 2|MP2)|(?<MP3VBR>MP3.*VBR|MPEG Version \d(.5)? Audio, Layer 3 vbr)|(?<MP3CBR>MP3|MPEG Version \d(.5)? Audio, Layer 3)|(?<FLAC>flac)|(?<WAVPACK>wavpack|wv)|(?<ALAC>alac)|(?<WMA>WMA\d?)|(?<WAV>WAV|PCM)|(?<AAC>M4A|M4P|M4B|AAC|mp4a|MPEG-4 Audio(?!.*alac))|(?<OGG>OGG|OGA|Vorbis))\b|(?<APE>monkey's audio|[\[|\(].*\bape\b.*[\]|\)])|(?<OPUS>Opus Version \d(.5)? Audio|[\[|\(].*\bopus\b.*[\]|\)])",
RegexOptions.Compiled | RegexOptions.IgnoreCase); RegexOptions.Compiled | RegexOptions.IgnoreCase);
public static QualityModel ParseQuality(string name, string desc, int fileBitrate, int fileSampleSize = 0) public static QualityModel ParseQuality(string name, string desc, int fileBitrate, int fileSampleSize = 0)

Loading…
Cancel
Save