From 5bf56ffca358782ff1b207b9c684f1a7aa222546 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 17 Feb 2012 16:14:56 -0800 Subject: [PATCH] Age parsing added to the indexers. --- NzbDrone.Core/Providers/Indexer/Newzbin.cs | 9 ++++++--- NzbDrone.Core/Providers/Indexer/Newznab.cs | 7 ++++++- NzbDrone.Core/Providers/Indexer/NzbMatrix.cs | 7 ++++++- NzbDrone.Core/Providers/Indexer/NzbsOrg.cs | 8 ++++++-- NzbDrone.Core/Providers/Indexer/NzbsRUs.cs | 7 ++++++- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/NzbDrone.Core/Providers/Indexer/Newzbin.cs b/NzbDrone.Core/Providers/Indexer/Newzbin.cs index c2a5af6f5..b6be66d94 100644 --- a/NzbDrone.Core/Providers/Indexer/Newzbin.cs +++ b/NzbDrone.Core/Providers/Indexer/Newzbin.cs @@ -105,16 +105,19 @@ namespace NzbDrone.Core.Providers.Indexer if (currentResult != null) { var quality = Parser.ParseQuality(item.Summary.Text); - currentResult.Quality = quality; var languageString = Regex.Match(item.Summary.Text, @"Language - \w*", RegexOptions.IgnoreCase).Value; - currentResult.Language = Parser.ParseLanguage(languageString); var sizeString = Regex.Match(item.Summary.Text, @"\(Size: \d*\,?\d+\.\d{1,2}\w{2}\)", RegexOptions.IgnoreCase).Value; - currentResult.Size = Parser.GetReportSize(sizeString); + + var dateString = Regex.Match(item.Summary.Text, + @"(?:\PostDate\:\s)(?.+?(AM|PM))(?:\s[a-zA-Z]+)(?:\<\/li\>)", + RegexOptions.IgnoreCase | RegexOptions.Compiled).Groups["date"].Value; + + currentResult.Age = DateTime.Today.Subtract(DateTime.Parse(dateString)).Days; } return currentResult; } diff --git a/NzbDrone.Core/Providers/Indexer/Newznab.cs b/NzbDrone.Core/Providers/Indexer/Newznab.cs index 76ed6995a..09b86fd11 100644 --- a/NzbDrone.Core/Providers/Indexer/Newznab.cs +++ b/NzbDrone.Core/Providers/Indexer/Newznab.cs @@ -80,8 +80,13 @@ namespace NzbDrone.Core.Providers.Indexer if (currentResult != null) { var sizeString = Regex.Match(item.Summary.Text, @">\d+\.\d{1,2} \w{2}", RegexOptions.IgnoreCase).Value; - currentResult.Size = Parser.GetReportSize(sizeString); + + var dateString = Regex.Match(item.Summary.Text, + @"(?:\)(?.+?)(?:\<\/pubDate\>)", + RegexOptions.IgnoreCase | RegexOptions.Compiled).Groups["date"].Value; + + currentResult.Age = DateTime.Today.Subtract(DateTime.Parse(dateString)).Days; } return currentResult; } diff --git a/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs b/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs index 89b758566..fd1813336 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs @@ -106,8 +106,13 @@ namespace NzbDrone.Core.Providers.Indexer if (currentResult != null) { var sizeString = Regex.Match(item.Summary.Text, @"Size: \d+\.\d{1,2} \w{2}
", RegexOptions.IgnoreCase).Value; - currentResult.Size = Parser.GetReportSize(sizeString); + + var dateString = Regex.Match(item.Summary.Text, + @"(?:\Added\:\<\/b\>)(?.+?)(?:\)", + RegexOptions.IgnoreCase | RegexOptions.Compiled).Groups["date"].Value; + + currentResult.Age = DateTime.Today.Subtract(DateTime.Parse(dateString)).Days; } return currentResult; } diff --git a/NzbDrone.Core/Providers/Indexer/NzbsOrg.cs b/NzbDrone.Core/Providers/Indexer/NzbsOrg.cs index e511972d1..34a988cbe 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbsOrg.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbsOrg.cs @@ -93,7 +93,6 @@ namespace NzbDrone.Core.Providers.Indexer get { return "Nzbs.org"; } } - protected override string NzbDownloadUrl(SyndicationItem item) { return item.Id; @@ -104,8 +103,13 @@ namespace NzbDrone.Core.Providers.Indexer if (currentResult != null) { var sizeString = Regex.Match(item.Summary.Text, @">\d+\.\d{1,2} \w{2}", RegexOptions.IgnoreCase).Value; - currentResult.Size = Parser.GetReportSize(sizeString); + + var dateString = Regex.Match(item.Summary.Text, + @"(?:\Posted\:\<\/b\>\s)(?.+?)(?:\s[a-zA-Z]+)(?:\)", + RegexOptions.IgnoreCase | RegexOptions.Compiled).Groups["date"].Value; + + currentResult.Age = DateTime.Today.Subtract(DateTime.Parse(dateString)).Days; } return currentResult; } diff --git a/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs b/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs index c98edc84e..ce43bc434 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs @@ -75,8 +75,13 @@ namespace NzbDrone.Core.Providers.Indexer if (currentResult != null) { var sizeString = Regex.Match(item.Summary.Text, @"\d+\.\d{1,2} \w{3}", RegexOptions.IgnoreCase).Value; - currentResult.Size = Parser.GetReportSize(sizeString); + + var dateString = Regex.Match(item.Summary.Text, + @"(?:\)(?.+?)(?:\<\/pubDate\>)", + RegexOptions.IgnoreCase | RegexOptions.Compiled).Groups["date"].Value; + + currentResult.Age = DateTime.Today.Subtract(DateTime.Parse(dateString)).Days; } return currentResult; }