From 0241e80c8aa11123871fdc5524d6b5318a39c464 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 18 Apr 2011 23:33:09 -0700 Subject: [PATCH] More quality parsing tests. Better series/episode info parsing. NzbMatrix and NzbsRUs Indexer Providers. --- NzbDrone.Core.Test/ParserTest.cs | 13 +++++-- NzbDrone.Core/NzbDrone.Core.csproj | 2 + NzbDrone.Core/Parser.cs | 25 ++++++++++-- .../Indexer/NzbMatrixFeedProvider.cs | 39 +++++++++++++++++++ .../Providers/Indexer/NzbsOrgProvider.cs | 4 +- .../Providers/Indexer/NzbsRUsFeedProvider.cs | 39 +++++++++++++++++++ 6 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 NzbDrone.Core/Providers/Indexer/NzbMatrixFeedProvider.cs create mode 100644 NzbDrone.Core/Providers/Indexer/NzbsRUsFeedProvider.cs diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index cf94b8e47..25dce37aa 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -10,6 +10,7 @@ namespace NzbDrone.Core.Test /*Fucked-up hall of shame, * WWE.Wrestlemania.27.PPV.HDTV.XviD-KYR * The.Kennedys.Part.2.DSR.XviD-SYS + * */ @@ -30,7 +31,7 @@ namespace NzbDrone.Core.Test [Row(@"The Event S01E14 A Message Back 720p WEB DL DD5 1 H264 SURFER", 1, 14)] [Row(@"Adam Hills In Gordon St Tonight S01E07 WS PDTV XviD FUtV", 1, 7)] [Row(@"Adam Hills In Gordon St Tonight S01E07 WS PDTV XviD FUtV", 1, 7)] - [Row("The.Kennedys.Part.2.DSR.XviD-SYS", 1, 2)] + //[Row("The.Kennedys.Part.2.DSR.XviD-SYS", 1, 2)] public void episode_parse(string path, int season, int episode) { var result = Parser.ParseEpisodeInfo(path); @@ -65,9 +66,13 @@ namespace NzbDrone.Core.Test } [Test] - [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", 3, new[] { 2, 3, 4, 5, 6 })] - //[Row("Two.and.a.Half.Men.103.104.720p.HDTV.X264-DIMENSION", 1, new[] {3, 4})] - //[Row("The.Kennedys.Part.1.and.Part.2.DSR.XviD-SYS", 1, new[] {1, 2})] + [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", 3, new[] { 1, 2, 3, 4, 5, 6 })] + [Row("Two.and.a.Half.Men.103.104.720p.HDTV.X264-DIMENSION", 1, new[] {3, 4})] + [Row("Weeds.S03E01.S03E02.720p.HDTV.X264-DIMENSION", 3, new[] {1, 2})] + [Row("The Borgias S01e01 e02 ShoHD On Demand 1080i DD5 1 ALANiS", 1, new[] { 1, 2 })] + [Row("Big Time Rush 1x01 to 10 480i DD2 0 Sianto", 1, new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 })] + [Row("White.Collar.2x04.2x05.720p.BluRay-FUTV", 2, new[] { 4, 5 })] + //[Row("The.Kennedys.Part.1.and.Part.2.DSR.XviD-SYS", 1, new[] { 1, 2 })] public void episode_multipart_parse(string path, int season, int[] episodes) { var result = Parser.ParseEpisodeInfo(path); diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index cfa1d4be8..7290c3408 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -169,6 +169,8 @@ + + diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index e691f15af..5b2aeb3b5 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -15,10 +15,10 @@ namespace NzbDrone.Core private static readonly Regex[] ReportTitleRegex = new[] { new Regex( - @"(?.+?)?\W?(?<year>\d+?)?\WS?(?<season>\d+)(?:\-|\.|[a-z])(?<episode>\d+)\W(?!\\)", + @"(?<title>.+?)?\W?(?<year>\d{4}?)?(?:\WS?(?<season>\d{1,2})(?:(?:\-|\.|[ex]|\s|to)+(?<episode>\d+))+)+\W?(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled), new Regex( - @"(?<title>.+?)?\W?(?<year>\d+?)?\WS?(?<season>\d+)(?<episode>\d{2})\W(?!\\)", + @"(?<title>.+?)?\W?(?<year>\d{4}?)?(?:\W(?<season>\d+)(?<episode>\d{2}))+\W?(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled) //Supports 103/113 naming }; @@ -45,7 +45,9 @@ namespace NzbDrone.Core foreach (var regex in ReportTitleRegex) { - var match = regex.Matches(title); + var simpleTitle = Regex.Replace(title, @"480[i|p]|720[i|p]|1080[i|p]|[x|h]264", String.Empty, RegexOptions.IgnoreCase | RegexOptions.Compiled); + + var match = regex.Matches(simpleTitle); if (match.Count != 0) { @@ -69,7 +71,22 @@ namespace NzbDrone.Core foreach (Match matchGroup in match) { - parsedEpisode.Episodes.Add(Convert.ToInt32(matchGroup.Groups["episode"].Value)); + var count = matchGroup.Groups["episode"].Captures.Count; + var first = Convert.ToInt32(matchGroup.Groups["episode"].Captures[0].Value); + var last = Convert.ToInt32(matchGroup.Groups["episode"].Captures[count - 1].Value); + + for (int i = first; i <= last; i++) + { + parsedEpisode.Episodes.Add(i); + } + + //else + //{ + // foreach (Capture ep in matchGroup.Groups["episode"].Captures) + // { + // parsedEpisode.Episodes.Add(Convert.ToInt32(ep.Value)); + // } + //} } parsedEpisode.Quality = ParseQuality(title); diff --git a/NzbDrone.Core/Providers/Indexer/NzbMatrixFeedProvider.cs b/NzbDrone.Core/Providers/Indexer/NzbMatrixFeedProvider.cs new file mode 100644 index 000000000..54a9cde94 --- /dev/null +++ b/NzbDrone.Core/Providers/Indexer/NzbMatrixFeedProvider.cs @@ -0,0 +1,39 @@ +using System.ServiceModel.Syndication; +using NzbDrone.Core.Providers.Core; +using SubSonic.Repository; + +namespace NzbDrone.Core.Providers.Indexer +{ + internal class NzbMatrixFeedProvider : IndexerProviderBase + { + public NzbMatrixFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider, IRepository repository, IndexerProvider indexerProvider) + : base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider, repository, indexerProvider) + { + } + + protected override string[] Url + { + get + { + return new[] + { + string.Format( + "http://rss.nzbmatrix.com/rss.php?page=download&username={0}&apikey={1}&subcat=6,41&english=1&scenename=1", + _configProvider.NzbMatrixUsername, + _configProvider.NzbMatrixApiKey) + }; + } + } + + + public override string Name + { + get { return "NzbMatrix"; } + } + + protected override string NzbDownloadUrl(SyndicationItem item) + { + return item.Links[0].ToString(); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/Providers/Indexer/NzbsOrgProvider.cs b/NzbDrone.Core/Providers/Indexer/NzbsOrgProvider.cs index 320bf9929..46468cff2 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbsOrgProvider.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbsOrgProvider.cs @@ -17,7 +17,7 @@ namespace NzbDrone.Core.Providers.Indexer { return new[] { - string.Format("http://nzbs.org/rss.php?type=1&i={0}&h={1}", _configProvider.NzbsOrgUId, _configProvider.NzbsOrgHash) + string.Format("http://nzbs.org/rss.php?type=1&i={0}&h={1}&num=50&dl=1", _configProvider.NzbsOrgUId, _configProvider.NzbsOrgHash) }; } } @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Providers.Indexer protected override string NzbDownloadUrl(SyndicationItem item) { - return item.Id.Replace("action=view", "action=getnzb"); + return item.Id; } diff --git a/NzbDrone.Core/Providers/Indexer/NzbsRUsFeedProvider.cs b/NzbDrone.Core/Providers/Indexer/NzbsRUsFeedProvider.cs new file mode 100644 index 000000000..c04388ac1 --- /dev/null +++ b/NzbDrone.Core/Providers/Indexer/NzbsRUsFeedProvider.cs @@ -0,0 +1,39 @@ +using System.ServiceModel.Syndication; +using NzbDrone.Core.Providers.Core; +using SubSonic.Repository; + +namespace NzbDrone.Core.Providers.Indexer +{ + internal class NzbsRUsFeedProvider : IndexerProviderBase + { + public NzbsRUsFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider, IRepository repository, IndexerProvider indexerProvider) + : base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider, repository, indexerProvider) + { + } + + protected override string[] Url + { + get + { + return new[] + { + string.Format( + "http://www.nzbsrus.com/rssfeed.php?cat=91,75&i={0}&h={1}", + _configProvider.NzbsrusUId, + _configProvider.NzbsrusHash) + }; + } + } + + + public override string Name + { + get { return "NzbsRUs"; } + } + + protected override string NzbDownloadUrl(SyndicationItem item) + { + return item.Links[0].ToString(); + } + } +} \ No newline at end of file