1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

Added REGEX to require Series name to exist (24-7 Penguin vs Capitals couldn't be parsed on disk properly)

REGEX replace replaces illegal windows file characters, except for " (quote)
This commit is contained in:
Mark McDowall 2011-04-30 17:23:10 -07:00
parent d4ef96f97b
commit 56a13b2511
2 changed files with 4 additions and 1 deletions

View File

@ -36,6 +36,7 @@ public class ParserTest
//[Row(@"Season 4\07 WS PDTV XviD FUtV", "", 4, 7)] //[Row(@"Season 4\07 WS PDTV XviD FUtV", "", 4, 7)]
[Row("The.Office.S03E115.DVDRip.XviD-OSiTV", "The.Office", 3, 115)] [Row("The.Office.S03E115.DVDRip.XviD-OSiTV", "The.Office", 3, 115)]
[Row(@"Parks and Recreation - S02E21 - 94 Meetings - 720p TV.mkv", "Parks and Recreation", 2, 21)] [Row(@"Parks and Recreation - S02E21 - 94 Meetings - 720p TV.mkv", "Parks and Recreation", 2, 21)]
[Row(@"24-7 Penguins-Capitals- Road to the NHL Winter Classic - S01E03 - Episode 3.mkv", "24-7 Penguins-Capitals- Road to the NHL Winter Classic", 1, 3)]
public void episode_parse(string postTitle, string title, int season, int episode) public void episode_parse(string postTitle, string title, int season, int episode)
{ {
var result = Parser.ParseEpisodeInfo(postTitle); var result = Parser.ParseEpisodeInfo(postTitle);

View File

@ -16,6 +16,8 @@ public static class Parser
{ {
new Regex(@"^(?<title>.+?)?\W*(?<airyear>\d{4})\W+(?<airmonth>\d{2})\W+(?<airday>\d{2})\W?(?!\\)", new Regex(@"^(?<title>.+?)?\W*(?<airyear>\d{4})\W+(?<airmonth>\d{2})\W+(?<airday>\d{2})\W?(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled), RegexOptions.IgnoreCase | RegexOptions.Compiled),
new Regex(@"^(?<title>.+?)(?:\WS?(?<season>\d{1,2}(?!\d+))(?:(?:\-|\.|[ex]|\s|\sto\s){1,2}(?<episode>\d{1,2}(?!\d+)))+)+\W?(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
new Regex(@"^(?<title>.*?)?(?:\W?S?(?<season>\d{1,2}(?!\d+))(?:(?:\-|\.|[ex]|\s|\sto\s){1,2}(?<episode>\d{1,2}(?!\d+)))+)+\W?(?!\\)", new Regex(@"^(?<title>.*?)?(?:\W?S?(?<season>\d{1,2}(?!\d+))(?:(?:\-|\.|[ex]|\s|\sto\s){1,2}(?<episode>\d{1,2}(?!\d+)))+)+\W?(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled), RegexOptions.IgnoreCase | RegexOptions.Compiled),
new Regex(@"^(?<title>.+?)?\W?(?:\W(?<season>\d+)(?<episode>\d{2}))+\W?(?!\\)", new Regex(@"^(?<title>.+?)?\W?(?:\W(?<season>\d+)(?<episode>\d{2}))+\W?(?!\\)",
@ -40,7 +42,7 @@ internal static EpisodeParseResult ParseEpisodeInfo(string title)
foreach (var regex in ReportTitleRegex) foreach (var regex in ReportTitleRegex)
{ {
var simpleTitle = Regex.Replace(title, @"480[i|p]|720[i|p]|1080[i|p]|[x|h]264", String.Empty, RegexOptions.IgnoreCase | RegexOptions.Compiled); var simpleTitle = Regex.Replace(title, @"480[i|p]|720[i|p]|1080[i|p]|[x|h]264|\\|\/|\<|\>|\?|\*|\:|\|", String.Empty, RegexOptions.IgnoreCase | RegexOptions.Compiled);
//Use only the filename, not the entire path //Use only the filename, not the entire path
var match = regex.Matches(new FileInfo(simpleTitle).Name); var match = regex.Matches(new FileInfo(simpleTitle).Name);