mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Fixed: Handle obfuscated files using abc.xyz pattern
Fixes #5105 Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
parent
a66b2cf416
commit
30c51ec4f3
104
src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs
Normal file
104
src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using FluentAssertions;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.ParserTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class CrapParserFixture : CoreTest
|
||||||
|
{
|
||||||
|
[TestCase("76El6LcgLzqb426WoVFg1vVVVGx4uCYopQkfjmLe")]
|
||||||
|
[TestCase("Vrq6e1Aba3U amCjuEgV5R2QvdsLEGYF3YQAQkw8")]
|
||||||
|
[TestCase("TDAsqTea7k4o6iofVx3MQGuDK116FSjPobMuh8oB")]
|
||||||
|
[TestCase("yp4nFodAAzoeoRc467HRh1mzuT17qeekmuJ3zFnL")]
|
||||||
|
[TestCase("oxXo8S2272KE1 lfppvxo3iwEJBrBmhlQVK1gqGc")]
|
||||||
|
[TestCase("dPBAtu681Ycy3A4NpJDH6kNVQooLxqtnsW1Umfiv")]
|
||||||
|
[TestCase("password - \"bdc435cb-93c4-4902-97ea-ca00568c3887.337\" yEnc")]
|
||||||
|
[TestCase("185d86a343e39f3341e35c4dad3f9959")]
|
||||||
|
[TestCase("ba27283b17c00d01193eacc02a8ba98eeb523a76")]
|
||||||
|
[TestCase("45a55debe3856da318cc35882ad07e43cd32fd15")]
|
||||||
|
[TestCase("86420f8ee425340d8894bf3bc636b66404b95f18")]
|
||||||
|
[TestCase("ce39afb7da6cf7c04eba3090f0a309f609883862")]
|
||||||
|
[TestCase("THIS SHOULD NEVER PARSE")]
|
||||||
|
[TestCase("Vh1FvU3bJXw6zs8EEUX4bMo5vbbMdHghxHirc.mkv")]
|
||||||
|
[TestCase("0e895c37245186812cb08aab1529cf8ee389dd05.mkv")]
|
||||||
|
[TestCase("08bbc153931ce3ca5fcafe1b92d3297285feb061.mkv")]
|
||||||
|
[TestCase("185d86a343e39f3341e35c4dad3ff159")]
|
||||||
|
[TestCase("ah63jka93jf0jh26ahjas961.mkv")]
|
||||||
|
[TestCase("qrdSD3rYzWb7cPdVIGSn4E7")]
|
||||||
|
[TestCase("QZC4HDl7ncmzyUj9amucWe1ddKU1oFMZDd8r0dEDUsTd")]
|
||||||
|
[TestCase("abc.xyz.af6021c37f7852")]
|
||||||
|
public void should_not_parse_crap(string title)
|
||||||
|
{
|
||||||
|
Parser.Parser.ParseMovieTitle(title).Should().BeNull();
|
||||||
|
ExceptionVerification.IgnoreWarns();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_parse_md5()
|
||||||
|
{
|
||||||
|
string hash = "CRAPPY TEST SEED";
|
||||||
|
|
||||||
|
var hashAlgo = System.Security.Cryptography.MD5.Create();
|
||||||
|
|
||||||
|
var repetitions = 100;
|
||||||
|
var success = 0;
|
||||||
|
for (int i = 0; i < repetitions; i++)
|
||||||
|
{
|
||||||
|
var hashData = hashAlgo.ComputeHash(Encoding.Default.GetBytes(hash));
|
||||||
|
|
||||||
|
hash = BitConverter.ToString(hashData).Replace("-", "");
|
||||||
|
|
||||||
|
if (Parser.Parser.ParseMovieTitle(hash) == null)
|
||||||
|
{
|
||||||
|
success++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
success.Should().Be(repetitions);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(32)]
|
||||||
|
[TestCase(40)]
|
||||||
|
public void should_not_parse_random(int length)
|
||||||
|
{
|
||||||
|
string charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
|
||||||
|
var hashAlgo = new Random();
|
||||||
|
|
||||||
|
var repetitions = 500;
|
||||||
|
var success = 0;
|
||||||
|
for (int i = 0; i < repetitions; i++)
|
||||||
|
{
|
||||||
|
StringBuilder hash = new StringBuilder(length);
|
||||||
|
|
||||||
|
for (int x = 0; x < length; x++)
|
||||||
|
{
|
||||||
|
hash.Append(charset[hashAlgo.Next() % charset.Length]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Parser.Parser.ParseMovieTitle(hash.ToString()) == null)
|
||||||
|
{
|
||||||
|
success++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
success.Should().Be(repetitions);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("thebiggestloser1618finale")]
|
||||||
|
public void should_not_parse_file_name_without_proper_spacing(string fileName)
|
||||||
|
{
|
||||||
|
Parser.Parser.ParseMovieTitle(fileName).Should().BeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("Big Forest (S01E18) Complete 360p HDTV AAC H.264-NEXT")]
|
||||||
|
public void should_not_parse_invalid_release_name(string fileName)
|
||||||
|
{
|
||||||
|
Parser.Parser.ParseMovieTitle(fileName).Should().BeNull();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
96
src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs
Normal file
96
src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
using FluentAssertions;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.ParserTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class HashedReleaseFixture : CoreTest
|
||||||
|
{
|
||||||
|
public static object[] HashedReleaseParserCases =
|
||||||
|
{
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
@"C:\Test\Some.Hashed.Release.2018.720p.WEB-DL.AAC2.0.H.264-Mercury\0e895c37245186812cb08aab1529cf8ee389dd05.mkv".AsOsAgnostic(),
|
||||||
|
"Some Hashed Release",
|
||||||
|
Quality.WEBDL720p,
|
||||||
|
"Mercury"
|
||||||
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
@"C:\Test\0e895c37245186812cb08aab1529cf8ee389dd05\Some.Hashed.Release.2018.720p.WEB-DL.AAC2.0.H.264-Mercury.mkv".AsOsAgnostic(),
|
||||||
|
"Some Hashed Release",
|
||||||
|
Quality.WEBDL720p,
|
||||||
|
"Mercury"
|
||||||
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
@"C:\Test\Weeds.2018.DVDRip.XviD-RADARR\AHFMZXGHEWD660.mkv".AsOsAgnostic(),
|
||||||
|
"Weeds",
|
||||||
|
Quality.DVD,
|
||||||
|
"RADARR"
|
||||||
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
@"C:\Test\Deadwood.2018.1080p.BluRay.x264-RADARR\Backup_72023S02-12.mkv".AsOsAgnostic(),
|
||||||
|
"Deadwood",
|
||||||
|
Quality.Bluray1080p,
|
||||||
|
null
|
||||||
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
@"C:\Test\Grimm 2018 720p WEB-DL DD5 1 H 264-ECI\123.mkv".AsOsAgnostic(),
|
||||||
|
"Grimm",
|
||||||
|
Quality.WEBDL720p,
|
||||||
|
"ECI"
|
||||||
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
@"C:\Test\Grimm 2018 720p WEB-DL DD5 1 H 264-ECI\abc.mkv".AsOsAgnostic(),
|
||||||
|
"Grimm",
|
||||||
|
Quality.WEBDL720p,
|
||||||
|
"ECI"
|
||||||
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
@"C:\Test\Grimm 2018 720p WEB-DL DD5 1 H 264-ECI\b00bs.mkv".AsOsAgnostic(),
|
||||||
|
"Grimm",
|
||||||
|
Quality.WEBDL720p,
|
||||||
|
"ECI"
|
||||||
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
@"C:\Test\The.Good.Wife.2018.720p.HDTV.x264-NZBgeek/cgajsofuejsa501.mkv".AsOsAgnostic(),
|
||||||
|
"The Good Wife",
|
||||||
|
Quality.HDTV720p,
|
||||||
|
"NZBgeek"
|
||||||
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
@"C:\Test\Fargo.2018.1080p.WEB-DL.DD5.1.H264-RARBG\170424_26.mkv".AsOsAgnostic(),
|
||||||
|
"Fargo",
|
||||||
|
Quality.WEBDL1080p,
|
||||||
|
"RARBG"
|
||||||
|
},
|
||||||
|
new object[]
|
||||||
|
{
|
||||||
|
@"C:\Test\Movie.Title.2018.720p.HDTV.H.264\abc.xyz.af6021c37f7852.mkv".AsOsAgnostic(),
|
||||||
|
"Movie Title",
|
||||||
|
Quality.HDTV720p,
|
||||||
|
null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCaseSource(nameof(HashedReleaseParserCases))]
|
||||||
|
public void should_properly_parse_hashed_releases(string path, string title, Quality quality, string releaseGroup)
|
||||||
|
{
|
||||||
|
var result = Parser.Parser.ParseMoviePath(path);
|
||||||
|
result.MovieTitle.Should().Be(title);
|
||||||
|
result.Quality.Quality.Should().Be(quality);
|
||||||
|
result.ReleaseGroup.Should().Be(releaseGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -76,6 +76,9 @@ public static class Parser
|
|||||||
//abc - Started appearing January 2015
|
//abc - Started appearing January 2015
|
||||||
new Regex(@"^abc$", RegexOptions.Compiled | RegexOptions.IgnoreCase),
|
new Regex(@"^abc$", RegexOptions.Compiled | RegexOptions.IgnoreCase),
|
||||||
|
|
||||||
|
//abc - Started appearing 2020
|
||||||
|
new Regex(@"^abc[-_. ]xyz", RegexOptions.Compiled | RegexOptions.IgnoreCase),
|
||||||
|
|
||||||
//b00bs - Started appearing January 2015
|
//b00bs - Started appearing January 2015
|
||||||
new Regex(@"^b00bs$", RegexOptions.Compiled | RegexOptions.IgnoreCase)
|
new Regex(@"^b00bs$", RegexOptions.Compiled | RegexOptions.IgnoreCase)
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user