more project cleanup.

pull/6/head
kay.one 12 years ago committed by Keivan Beigi
parent 5d7f6fb03b
commit 401ed9a8f6

@ -0,0 +1,37 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.IndexerTests
{
public class BasicRssParserFixture : CoreTest<BasicRssParser>
{
[TestCase("Castle.2009.S01E14.English.HDTV.XviD-LOL", "LOL")]
[TestCase("Castle 2009 S01E14 English HDTV XviD LOL", "LOL")]
[TestCase("Acropolis Now S05 EXTRAS DVDRip XviD RUNNER", "RUNNER")]
[TestCase("Punky.Brewster.S01.EXTRAS.DVDRip.XviD-RUNNER", "RUNNER")]
[TestCase("2020.NZ.2011.12.02.PDTV.XviD-C4TV", "C4TV")]
[TestCase("The.Office.S03E115.DVDRip.XviD-OSiTV", "OSiTV")]
public void parse_releaseGroup(string title, string expected)
{
BasicRssParser.ParseReleaseGroup(title).Should().Be(expected);
}
[TestCase("5.64 GB", 6055903887)]
[TestCase("5.54 GiB", 5948529705)]
[TestCase("398.62 MiB", 417983365)]
[TestCase("7,162.1MB", 7510006170)]
[TestCase("162.1MB", 169974170)]
[TestCase("398.62 MB", 417983365)]
public void parse_size(string sizeString, long expectedSize)
{
var result = BasicRssParser.GetReportSize(sizeString);
result.Should().Be(expectedSize);
}
}
}

@ -134,6 +134,7 @@
<Compile Include="Framework\DbTest.cs" /> <Compile Include="Framework\DbTest.cs" />
<Compile Include="Framework\NBuilderExtensions.cs" /> <Compile Include="Framework\NBuilderExtensions.cs" />
<Compile Include="IndexerSearchTests\SearchDefinitionFixture.cs" /> <Compile Include="IndexerSearchTests\SearchDefinitionFixture.cs" />
<Compile Include="IndexerTests\BasicRssParserFixture.cs" />
<Compile Include="JobTests\JobRepositoryFixture.cs" /> <Compile Include="JobTests\JobRepositoryFixture.cs" />
<Compile Include="JobTests\RenameSeasonJobFixture.cs" /> <Compile Include="JobTests\RenameSeasonJobFixture.cs" />
<Compile Include="DecisionEngineTests\LanguageSpecificationFixture.cs" /> <Compile Include="DecisionEngineTests\LanguageSpecificationFixture.cs" />

@ -4,6 +4,7 @@ using FluentAssertions;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common.Contract; using NzbDrone.Common.Contract;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
@ -325,8 +326,8 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("Burn.Notice.S04E15.Brotherly.Love.GERMAN.DUBBED.WS.WEBRiP.XviD.REPACK-TVP", LanguageType.German)] [TestCase("Burn.Notice.S04E15.Brotherly.Love.GERMAN.DUBBED.WS.WEBRiP.XviD.REPACK-TVP", LanguageType.German)]
public void parse_language(string postTitle, LanguageType language) public void parse_language(string postTitle, LanguageType language)
{ {
var result = Parser.ParseLanguage(postTitle); var result = Parser.ParseTitle<ParseResult>(postTitle);
result.Should().Be(language); result.Language.Should().Be(language);
} }
[TestCase("Hawaii Five 0 S01 720p WEB DL DD5 1 H 264 NT", "Hawaii Five", 1)] [TestCase("Hawaii Five 0 S01 720p WEB DL DD5 1 H 264 NT", "Hawaii Five", 1)]
@ -346,19 +347,6 @@ namespace NzbDrone.Core.Test.ParserTests
result.OriginalString.Should().Be(postTitle); result.OriginalString.Should().Be(postTitle);
} }
[TestCase("5.64 GB", 6055903887)]
[TestCase("5.54 GiB", 5948529705)]
[TestCase("398.62 MiB", 417983365)]
[TestCase("7,162.1MB", 7510006170)]
[TestCase("162.1MB", 169974170)]
[TestCase("398.62 MB", 417983365)]
public void parse_size(string sizeString, long expectedSize)
{
var result = Parser.GetReportSize(sizeString);
result.Should().Be(expectedSize);
}
[TestCase("Acropolis Now S05 EXTRAS DVDRip XviD RUNNER")] [TestCase("Acropolis Now S05 EXTRAS DVDRip XviD RUNNER")]
[TestCase("Punky Brewster S01 EXTRAS DVDRip XviD RUNNER")] [TestCase("Punky Brewster S01 EXTRAS DVDRip XviD RUNNER")]
[TestCase("Instant Star S03 EXTRAS DVDRip XviD OSiTV")] [TestCase("Instant Star S03 EXTRAS DVDRip XviD OSiTV")]
@ -392,7 +380,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("[ 21154 ] - [ TrollHD ] - [ 00/73 ] - \"MythBusters S03E20 Escape Slide Parachute 1080i HDTV-UPSCALE DD5.1 MPEG2-TrollHD.nzb\" yEnc", "MythBusters S03E20 Escape Slide Parachute 1080i HDTV-UPSCALE DD5.1 MPEG2-TrollHD.nzb")] [TestCase("[ 21154 ] - [ TrollHD ] - [ 00/73 ] - \"MythBusters S03E20 Escape Slide Parachute 1080i HDTV-UPSCALE DD5.1 MPEG2-TrollHD.nzb\" yEnc", "MythBusters S03E20 Escape Slide Parachute 1080i HDTV-UPSCALE DD5.1 MPEG2-TrollHD.nzb")]
public void parse_header(string title, string expected) public void parse_header(string title, string expected)
{ {
Parser.ParseHeader(title).Should().Be(expected); BasicRssParser.ParseHeader(title).Should().Be(expected);
} }
[TestCase("password - \"bdc435cb-93c4-4902-97ea-ca00568c3887.337\" yEnc")] [TestCase("password - \"bdc435cb-93c4-4902-97ea-ca00568c3887.337\" yEnc")]

@ -4,13 +4,14 @@ using System;
using System.Linq; using System.Linq;
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ParserTests namespace NzbDrone.Core.Test.ParserTests
{ {
[TestFixture] [TestFixture]
public class QualityParserFixture : CoreTest public class QualityParserFixture : CoreTest
{ {
public static object[] QualityParserCases = public static object[] QualityParserCases =
@ -96,17 +97,17 @@ namespace NzbDrone.Core.Test.ParserTests
[Test, TestCaseSource("QualityParserCases")] [Test, TestCaseSource("QualityParserCases")]
public void quality_parse(string postTitle, Quality quality, bool proper) public void quality_parse(string postTitle, Quality quality, bool proper)
{ {
var result = Parser.ParseQuality(postTitle); var result = Parser.ParseTitle<ParseResult>(postTitle);
result.Quality.Should().Be(quality); result.Quality.Quality.Should().Be(quality);
result.Proper.Should().Be(proper); result.Quality.Proper.Should().Be(proper);
} }
[Test, TestCaseSource("SelfQualityParserCases")] [Test, TestCaseSource("SelfQualityParserCases")]
public void parsing_our_own_quality_enum(Quality quality) public void parsing_our_own_quality_enum(Quality quality)
{ {
var fileName = String.Format("My series S01E01 [{0}]", quality); var fileName = String.Format("My series S01E01 [{0}]", quality);
var result = Parser.ParseQuality(fileName); var result = Parser.ParseTitle<ParseResult>(fileName);
result.Quality.Should().Be(quality); result.Quality.Quality.Should().Be(quality);
} }
} }
} }

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Core.Download;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Download.Clients.Nzbget; using NzbDrone.Core.Download.Clients.Nzbget;
using NzbDrone.Core.Download.Clients.Sabnzbd; using NzbDrone.Core.Download.Clients.Sabnzbd;

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Core.Download;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Download.Clients.Nzbget; using NzbDrone.Core.Download.Clients.Nzbget;
using NzbDrone.Core.Download.Clients.Sabnzbd; using NzbDrone.Core.Download.Clients.Sabnzbd;

@ -1,4 +1,4 @@
namespace NzbDrone.Core.Model namespace NzbDrone.Core.Download.Clients
{ {
public class ConnectionInfoModel public class ConnectionInfoModel
{ {

@ -1,4 +1,4 @@
namespace NzbDrone.Core.Model namespace NzbDrone.Core.Download
{ {
public enum DownloadClientType public enum DownloadClientType
{ {

@ -1,7 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.ServiceModel.Syndication; using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using NLog; using NLog;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
@ -63,7 +65,7 @@ namespace NzbDrone.Core.Indexers
protected virtual string GetNzbInfoUrl(SyndicationItem item) protected virtual string GetNzbInfoUrl(SyndicationItem item)
{ {
return string.Empty; return String.Empty;
} }
protected virtual IndexerParseResult PostProcessor(SyndicationItem item, IndexerParseResult currentResult) protected virtual IndexerParseResult PostProcessor(SyndicationItem item, IndexerParseResult currentResult)
@ -89,7 +91,7 @@ namespace NzbDrone.Core.Indexers
return PostProcessor(item, episodeParseResult); return PostProcessor(item, episodeParseResult);
} }
private static string ParseReleaseGroup(string title) public static string ParseReleaseGroup(string title)
{ {
title = title.Trim(); title = title.Trim();
var index = title.LastIndexOf('-'); var index = title.LastIndexOf('-');
@ -102,10 +104,59 @@ namespace NzbDrone.Core.Indexers
var group = title.Substring(index + 1); var group = title.Substring(index + 1);
if (group.Length == title.Length) if (@group.Length == title.Length)
return String.Empty; return String.Empty;
return group; return @group;
}
private static readonly Regex[] HeaderRegex = new[]
{
new Regex(@"(?:\[.+\]\-\[.+\]\-\[.+\]\-\[)(?<nzbTitle>.+)(?:\]\-.+)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
new Regex(@"(?:\[.+\]\W+\[.+\]\W+\[.+\]\W+\"")(?<nzbTitle>.+)(?:\"".+)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
new Regex(@"(?:\[)(?<nzbTitle>.+)(?:\]\-.+)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
};
public static string ParseHeader(string header)
{
foreach (var regex in HeaderRegex)
{
var match = regex.Matches(header);
if (match.Count != 0)
return match[0].Groups["nzbTitle"].Value.Trim();
}
return header;
}
private static readonly Regex ReportSizeRegex = new Regex(@"(?<value>\d+\.\d{1,2}|\d+\,\d+\.\d{1,2})\W?(?<unit>GB|MB|GiB|MiB)",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
public static long GetReportSize(string sizeString)
{
var match = ReportSizeRegex.Matches(sizeString);
if (match.Count != 0)
{
var cultureInfo = new CultureInfo("en-US");
var value = Decimal.Parse(Regex.Replace(match[0].Groups["value"].Value, "\\,", ""), cultureInfo);
var unit = match[0].Groups["unit"].Value;
if (unit.Equals("MB", StringComparison.InvariantCultureIgnoreCase) || unit.Equals("MiB", StringComparison.InvariantCultureIgnoreCase))
return Convert.ToInt64(value * 1048576L);
if (unit.Equals("GB", StringComparison.InvariantCultureIgnoreCase) || unit.Equals("GiB", StringComparison.InvariantCultureIgnoreCase))
return Convert.ToInt64(value * 1073741824L);
}
return 0;
} }
} }
} }

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace NzbDrone.Core.Indexers.Newznab namespace NzbDrone.Core.Indexers.Newznab
{ {
@ -20,39 +21,22 @@ namespace NzbDrone.Core.Indexers.Newznab
public override IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) public override IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{ {
foreach (var url in RecentFeed) return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}&season={2}&ep={3}", url, NewsnabifyTitle(seriesTitle), seasonNumber, episodeNumber));
{
yield return String.Format("{0}&limit=100&q={1}&season={2}&ep={3}", url, NewsnabifyTitle(seriesTitle), seasonNumber, episodeNumber);
}
} }
public override IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date) public override IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
{ {
var searchUrls = new List<string>(); return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}&season={2:yyyy}&ep={2:MM/dd}", url, NewsnabifyTitle(seriesTitle), date)).ToList();
foreach (var url in RecentFeed)
{
searchUrls.Add(String.Format("{0}&limit=100&q={1}&season={2:yyyy}&ep={2:MM/dd}", url, NewsnabifyTitle(seriesTitle), date));
}
return searchUrls;
} }
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber) public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
{ {
foreach (var url in RecentFeed) return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}&season={2}", url, NewsnabifyTitle(seriesTitle), seasonNumber));
{
yield return String.Format("{0}&limit=100&q={1}&season={2}", url, NewsnabifyTitle(seriesTitle), seasonNumber);
}
} }
public override IEnumerable<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard) public override IEnumerable<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
{ {
foreach (var url in RecentFeed) return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}+S{2:00}E{3}", url, NewsnabifyTitle(seriesTitle), seasonNumber, episodeWildcard));
{
yield return
String.Format("{0}&limit=100&q={1}+S{2:00}E{3}", url, NewsnabifyTitle(seriesTitle), seasonNumber, episodeWildcard);
}
} }
public override string Name public override string Name

@ -12,7 +12,7 @@ namespace NzbDrone.Core.Indexers.NzbClub
if (currentResult != null) if (currentResult != null)
{ {
var sizeString = Regex.Match(item.Summary.Text, @"Size:\s\d+\.\d{1,2}\s\w{2}\s", RegexOptions.IgnoreCase | RegexOptions.Compiled).Value; var sizeString = Regex.Match(item.Summary.Text, @"Size:\s\d+\.\d{1,2}\s\w{2}\s", RegexOptions.IgnoreCase | RegexOptions.Compiled).Value;
currentResult.Size = Parser.GetReportSize(sizeString); currentResult.Size = GetReportSize(sizeString);
} }
return currentResult; return currentResult;
@ -20,7 +20,7 @@ namespace NzbDrone.Core.Indexers.NzbClub
protected override string GetTitle(SyndicationItem syndicationItem) protected override string GetTitle(SyndicationItem syndicationItem)
{ {
var title = Parser.ParseHeader(syndicationItem.Title.Text); var title = ParseHeader(syndicationItem.Title.Text);
if (String.IsNullOrWhiteSpace(title)) if (String.IsNullOrWhiteSpace(title))
return syndicationItem.Title.Text; return syndicationItem.Title.Text;

@ -23,18 +23,18 @@ namespace NzbDrone.Core.Indexers.NzbIndex
if (currentResult != null) if (currentResult != null)
{ {
var sizeString = Regex.Match(item.Summary.Text, @"<b>\d+\.\d{1,2}\s\w{2}</b><br\s/>", RegexOptions.IgnoreCase | RegexOptions.Compiled).Value; var sizeString = Regex.Match(item.Summary.Text, @"<b>\d+\.\d{1,2}\s\w{2}</b><br\s/>", RegexOptions.IgnoreCase | RegexOptions.Compiled).Value;
currentResult.Size = Parser.GetReportSize(sizeString); currentResult.Size = GetReportSize(sizeString);
} }
return currentResult; return currentResult;
} }
protected override string GetTitle(SyndicationItem item) protected override string GetTitle(SyndicationItem syndicationItem)
{ {
var title = Parser.ParseHeader(item.Title.Text); var title = ParseHeader(syndicationItem.Title.Text);
if (String.IsNullOrWhiteSpace(title)) if (String.IsNullOrWhiteSpace(title))
return item.Title.Text; return syndicationItem.Title.Text;
return title; return title;
} }

@ -11,7 +11,7 @@ namespace NzbDrone.Core.Indexers.NzbsRUs
if (currentResult != null) if (currentResult != null)
{ {
var sizeString = Regex.Match(item.Summary.Text, @"\d+\.\d{1,2} \w{3}", RegexOptions.IgnoreCase).Value; var sizeString = Regex.Match(item.Summary.Text, @"\d+\.\d{1,2} \w{3}", RegexOptions.IgnoreCase).Value;
currentResult.Size = Parser.GetReportSize(sizeString); currentResult.Size = GetReportSize(sizeString);
} }
return currentResult; return currentResult;

@ -4,7 +4,6 @@ using System.IO;
using NLog; using NLog;
using Newtonsoft.Json; using Newtonsoft.Json;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Nzbx;
namespace NzbDrone.Core.Indexers.Nzbx namespace NzbDrone.Core.Indexers.Nzbx
{ {

@ -1,9 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Nzbx namespace NzbDrone.Core.Indexers.Nzbx
{ {
public class NzbxRecentItem public class NzbxRecentItem
{ {
@ -42,6 +39,5 @@ namespace NzbDrone.Core.Model.Nzbx
public int RageId { get; set; } public int RageId { get; set; }
public int Comments { get; set; } public int Comments { get; set; }
public int Downloads { get; set; } public int Downloads { get; set; }
public NzbxVotesModel Votes { get; set; }
} }
} }

@ -31,7 +31,7 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs
if (currentResult != null) if (currentResult != null)
{ {
var sizeString = Regex.Match(item.Summary.Text, @"Size:\<\/b\>\s\d+\.\d{1,2}\s\w{2}\<br \/\>", RegexOptions.IgnoreCase | RegexOptions.Compiled).Value; var sizeString = Regex.Match(item.Summary.Text, @"Size:\<\/b\>\s\d+\.\d{1,2}\s\w{2}\<br \/\>", RegexOptions.IgnoreCase | RegexOptions.Compiled).Value;
currentResult.Size = Parser.GetReportSize(sizeString); currentResult.Size = GetReportSize(sizeString);
} }
return currentResult; return currentResult;

@ -72,7 +72,7 @@ namespace NzbDrone.Core.Indexers
return dateVal; return dateVal;
} }
internal void CheckForError() public void CheckForError()
{ {
if (this.MoveToContent() == XmlNodeType.Element) if (this.MoveToContent() == XmlNodeType.Element)
{ {

@ -1,47 +0,0 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace NzbDrone.Core.Model.Nzbx.JsonConverter
{
public class EpochDateTimeConverter : DateTimeConverterBase
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
long ticks;
if (value is DateTime)
{
var epoch = new DateTime(1970, 1, 1);
var delta = ((DateTime)value) - epoch;
if (delta.TotalSeconds < 0)
{
throw new ArgumentOutOfRangeException("value",
"Unix epoc starts January 1st, 1970");
}
ticks = (long)delta.TotalSeconds;
}
else
{
throw new Exception("Expected date object value.");
}
writer.WriteValue(ticks);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType != JsonToken.Integer)
{
throw new Exception(
String.Format("Unexpected token parsing date. Expected Integer, got {0}.",
reader.TokenType));
}
var ticks = (long)reader.Value;
var date = new DateTime(1970, 1, 1);
date = date.AddSeconds(ticks);
return date;
}
}
}

@ -1,56 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using NzbDrone.Core.Model.Nzbx.JsonConverter;
namespace NzbDrone.Core.Model.Nzbx
{
public class NzbxSearchItem
{
//"name": "30.Rock.S06E06E07.HDTV.XviD-LOL",
//"fromname": "teevee@4u.tv (teevee)",
//"size": 418067671,
//"groupid": 4,
//"categoryid": 5030,
//"totalpart": 36,
//"completion": 100,
//"rageid": "-1",
//"imdbid": "",
//"comments": "0",
//"guid": "97be14dbf1776eec4fb8f2bb835935c0",
//"adddate": 1355343562,
//"postdate": 1328839361,
//"downloads": "0",
//"votes": {
// "upvotes": 0,
// "downvotes": 0
//},
//"nzb": "https://nzbx.co/nzb?97be14dbf1776eec4fb8f2bb835935c0*|*30.Rock.S06E06E07.HDTV.XviD-LOL
public string Name { get; set; }
public int TotalPart { get; set; }
public int GroupId { get; set; }
public long Size { get; set; }
[JsonConverter(typeof(EpochDateTimeConverter))]
public DateTime AddDate { get; set; }
[JsonConverter(typeof(EpochDateTimeConverter))]
public DateTime PostDate { get; set; }
public string Guid { get; set; }
public string FromName { get; set; }
public int Completion { get; set; }
public int CategoryId { get; set; }
public string ImdbId { get; set; }
public int RageId { get; set; }
public int Comments { get; set; }
public int Downloads { get; set; }
public NzbxVotesModel Votes { get; set; }
public string Nzb { get; set; }
}
}

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model.Nzbx
{
public class NzbxVotesModel
{
public int Up { get; set; }
public int Down { get; set; }
}
}

@ -1,18 +0,0 @@
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Model
{
public class SeasonParseResult
{
internal string SeriesTitle { get; set; }
internal int SeasonNumber { get; set; }
internal int Year { get; set; }
public QualityModel Quality { get; set; }
public override string ToString()
{
return string.Format("Series:{0} Season:{1}", SeriesTitle, SeasonNumber);
}
}
}

@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
{
public class StatsModel
{
[DisplayName("Number of Series")]
public int SeriesTotal { get; set; }
[DisplayName("Number of Series Countinuing")]
public int SeriesContinuing { get; set; }
[DisplayName("Number of Series Ended")]
public int SeriesEnded { get; set; }
[DisplayName("Number of Episodes")]
public int EpisodesTotal { get; set; }
[DisplayName("Number of Episodes On Disk")]
public int EpisodesOnDisk { get; set; }
[DisplayName("Number of Episodes Missing")]
public int EpisodesMissing { get; set; }
[DisplayName("Downloaded in the Last Week")]
public int DownloadLastWeek { get; set; }
[DisplayName("Downloaded in the Last 30 days")]
public int DownloadedLastMonth { get; set; }
}
}

@ -230,16 +230,17 @@
<Compile Include="DecisionEngine\Specifications\Search\SingleEpisodeMatchSpecification.cs" /> <Compile Include="DecisionEngine\Specifications\Search\SingleEpisodeMatchSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\UpgradeDiskSpecification.cs" /> <Compile Include="DecisionEngine\Specifications\UpgradeDiskSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\UpgradeHistorySpecification.cs" /> <Compile Include="DecisionEngine\Specifications\UpgradeHistorySpecification.cs" />
<Compile Include="Download\Clients\ConnectionInfoModel.cs" />
<Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdPriorityTypeConverter.cs" /> <Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdPriorityTypeConverter.cs" />
<Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdQueueTimeConverter.cs" /> <Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdQueueTimeConverter.cs" />
<Compile Include="Download\Clients\Sabnzbd\SabAutoConfigureService.cs" /> <Compile Include="Download\Clients\Sabnzbd\SabAutoConfigureService.cs" />
<Compile Include="Download\DownloadClientProvider.cs" /> <Compile Include="Download\DownloadClientProvider.cs" />
<Compile Include="Download\DownloadClientType.cs" />
<Compile Include="MediaFiles\Events\EpisodeDownloadedEvent.cs" /> <Compile Include="MediaFiles\Events\EpisodeDownloadedEvent.cs" />
<Compile Include="Download\EpisodeGrabbedEvent.cs" /> <Compile Include="Download\EpisodeGrabbedEvent.cs" />
<Compile Include="Download\SeriesRenamedEvent.cs" /> <Compile Include="Download\SeriesRenamedEvent.cs" />
<Compile Include="ExternalNotification\ExternalNotificationRepository.cs" /> <Compile Include="ExternalNotification\ExternalNotificationRepository.cs" />
<Compile Include="Fluent.cs" /> <Compile Include="Fluent.cs" />
<Compile Include="Model\Nzbx\JsonConverter\EpochDateTimeConverter.cs" />
<Compile Include="Helpers\SortHelper.cs" /> <Compile Include="Helpers\SortHelper.cs" />
<Compile Include="History\HistoryRepository.cs" /> <Compile Include="History\HistoryRepository.cs" />
<Compile Include="IndexerSearch\Definitions\DailyEpisodeSearchDefinition.cs" /> <Compile Include="IndexerSearch\Definitions\DailyEpisodeSearchDefinition.cs" />
@ -321,11 +322,9 @@
<Compile Include="MetadataSource\Trakt\TopWatcher.cs" /> <Compile Include="MetadataSource\Trakt\TopWatcher.cs" />
<Compile Include="Organizer\EpisodeSortingType.cs" /> <Compile Include="Organizer\EpisodeSortingType.cs" />
<Compile Include="Organizer\FileNameBuilder.cs" /> <Compile Include="Organizer\FileNameBuilder.cs" />
<Compile Include="Model\DownloadClientType.cs" />
<Compile Include="Instrumentation\LogService.cs" /> <Compile Include="Instrumentation\LogService.cs" />
<Compile Include="Instrumentation\DatabaseTarget.cs" /> <Compile Include="Instrumentation\DatabaseTarget.cs" />
<Compile Include="Model\AtomicParsleyTitleType.cs" /> <Compile Include="Model\AtomicParsleyTitleType.cs" />
<Compile Include="Model\ConnectionInfoModel.cs" />
<Compile Include="Model\BacklogSettingType.cs" /> <Compile Include="Model\BacklogSettingType.cs" />
<Compile Include="Model\MediaInfoModel.cs" /> <Compile Include="Model\MediaInfoModel.cs" />
<Compile Include="Download\Clients\Nzbget\EnqueueResponse.cs" /> <Compile Include="Download\Clients\Nzbget\EnqueueResponse.cs" />
@ -336,9 +335,7 @@
<Compile Include="Download\Clients\Nzbget\QueueItem.cs" /> <Compile Include="Download\Clients\Nzbget\QueueItem.cs" />
<Compile Include="Download\Clients\Nzbget\PriorityType.cs" /> <Compile Include="Download\Clients\Nzbget\PriorityType.cs" />
<Compile Include="Download\Clients\Nzbget\VersionModel.cs" /> <Compile Include="Download\Clients\Nzbget\VersionModel.cs" />
<Compile Include="Model\Nzbx\NzbxSearchItem.cs" /> <Compile Include="Indexers\Nzbx\NzbxRecentItem.cs" />
<Compile Include="Model\Nzbx\NzbxRecentItem.cs" />
<Compile Include="Model\Nzbx\NzbxVotesModel.cs" />
<Compile Include="Model\PostDownloadStatusType.cs" /> <Compile Include="Model\PostDownloadStatusType.cs" />
<Compile Include="Model\LanguageType.cs" /> <Compile Include="Model\LanguageType.cs" />
<Compile Include="Model\MisnamedEpisodeModel.cs" /> <Compile Include="Model\MisnamedEpisodeModel.cs" />
@ -363,7 +360,6 @@
<Compile Include="Download\Clients\Sabnzbd\SabModel.cs" /> <Compile Include="Download\Clients\Sabnzbd\SabModel.cs" />
<Compile Include="Download\Clients\Sabnzbd\SabQueueItem.cs" /> <Compile Include="Download\Clients\Sabnzbd\SabQueueItem.cs" />
<Compile Include="Download\Clients\Sabnzbd\SabVersionModel.cs" /> <Compile Include="Download\Clients\Sabnzbd\SabVersionModel.cs" />
<Compile Include="Model\StatsModel.cs" />
<Compile Include="Model\Twitter\TwitterAuthorizationModel.cs" /> <Compile Include="Model\Twitter\TwitterAuthorizationModel.cs" />
<Compile Include="Model\UpdatePackage.cs" /> <Compile Include="Model\UpdatePackage.cs" />
<Compile Include="Model\Xbmc\ActionType.cs" /> <Compile Include="Model\Xbmc\ActionType.cs" />
@ -512,7 +508,6 @@
<Compile Include="Model\IndexerParseResult.cs" /> <Compile Include="Model\IndexerParseResult.cs" />
<Compile Include="Model\EpisodeStatusType.cs" /> <Compile Include="Model\EpisodeStatusType.cs" />
<Compile Include="Download\Clients\Sabnzbd\SabPriorityType.cs" /> <Compile Include="Download\Clients\Sabnzbd\SabPriorityType.cs" />
<Compile Include="Model\SeasonParseResult.cs" />
<Compile Include="MediaFiles\EpisodeFile.cs" /> <Compile Include="MediaFiles\EpisodeFile.cs" />
<Compile Include="Model\Notification\ProgressNotificationStatus.cs" /> <Compile Include="Model\Notification\ProgressNotificationStatus.cs" />
<Compile Include="Parser.cs" /> <Compile Include="Parser.cs" />

@ -53,7 +53,7 @@ namespace NzbDrone.Core
new Regex(@"^(?<title>.+?)?(?:\W?(?<season>(?<!\d+)\d{1})(?<episode>\d{2}(?!p|i|\d+)))+\W?(?!\\)", new Regex(@"^(?<title>.+?)?(?:\W?(?<season>(?<!\d+)\d{1})(?<episode>\d{2}(?!p|i|\d+)))+\W?(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled), RegexOptions.IgnoreCase | RegexOptions.Compiled),
//Mini-Series, treated as season 1, episodes are labeled as Part01, Part 01, Part.1 //Mini-Series, treated as season 1, episodes are labelled as Part01, Part 01, Part.1
new Regex(@"^(?<title>.+?)(?:\W+(?:(?:Part\W?|(?<!\d+\W+)e)(?<episode>\d{1,2}(?!\d+)))+)\W?(?!\\)", new Regex(@"^(?<title>.+?)(?:\W+(?:(?:Part\W?|(?<!\d+\W+)e)(?<episode>\d{1,2}(?!\d+)))+)\W?(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled), RegexOptions.IgnoreCase | RegexOptions.Compiled),
@ -72,26 +72,13 @@ namespace NzbDrone.Core
private static readonly Regex SimpleTitleRegex = new Regex(@"480[i|p]|720[i|p]|1080[i|p]|[x|h|x\s|h\s]264|DD\W?5\W1|\<|\>|\?|\*|\:|\||""", private static readonly Regex SimpleTitleRegex = new Regex(@"480[i|p]|720[i|p]|1080[i|p]|[x|h|x\s|h\s]264|DD\W?5\W1|\<|\>|\?|\*|\:|\||""",
RegexOptions.IgnoreCase | RegexOptions.Compiled); RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex ReportSizeRegex = new Regex(@"(?<value>\d+\.\d{1,2}|\d+\,\d+\.\d{1,2})\W?(?<unit>GB|MB|GiB|MiB)",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex[] HeaderRegex = new[]
{
new Regex(@"(?:\[.+\]\-\[.+\]\-\[.+\]\-\[)(?<nzbTitle>.+)(?:\]\-.+)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
new Regex(@"(?:\[.+\]\W+\[.+\]\W+\[.+\]\W+\"")(?<nzbTitle>.+)(?:\"".+)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
new Regex(@"(?:\[)(?<nzbTitle>.+)(?:\]\-.+)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
};
private static readonly Regex MultiPartCleanupRegex = new Regex(@"\(\d+\)$", RegexOptions.Compiled); private static readonly Regex MultiPartCleanupRegex = new Regex(@"\(\d+\)$", RegexOptions.Compiled);
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?<italian>ita|italian)|(?<german>german\b)|(?<flemish>flemish)|(?<greek>greek)(?:\W|_)", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_)(?<italian>ita|italian)|(?<german>german\b)|(?<flemish>flemish)|(?<greek>greek)(?:\W|_)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
internal static FileNameParseResult ParsePath(string path) public static FileNameParseResult ParsePath(string path)
{ {
var fileInfo = new FileInfo(path); var fileInfo = new FileInfo(path);
@ -115,7 +102,7 @@ namespace NzbDrone.Core
return result; return result;
} }
internal static T ParseTitle<T>(string title) where T : ParseResult, new() public static T ParseTitle<T>(string title) where T : ParseResult, new()
{ {
try try
{ {
@ -158,12 +145,12 @@ namespace NzbDrone.Core
{ {
var seriesName = matchCollection[0].Groups["title"].Value.Replace('.', ' '); var seriesName = matchCollection[0].Groups["title"].Value.Replace('.', ' ');
int airyear; int airYear;
Int32.TryParse(matchCollection[0].Groups["airyear"].Value, out airyear); Int32.TryParse(matchCollection[0].Groups["airyear"].Value, out airYear);
T parsedIndexer; T result;
if (airyear < 1900) if (airYear < 1900)
{ {
var seasons = new List<int>(); var seasons = new List<int>();
@ -182,7 +169,7 @@ namespace NzbDrone.Core
if (seasons.Distinct().Count() > 1) if (seasons.Distinct().Count() > 1)
return null; return null;
parsedIndexer = new T result = new T
{ {
SeasonNumber = seasons.First(), SeasonNumber = seasons.First(),
EpisodeNumbers = new List<int>() EpisodeNumbers = new List<int>()
@ -197,7 +184,7 @@ namespace NzbDrone.Core
{ {
var first = Convert.ToInt32(episodeCaptures.First().Value); var first = Convert.ToInt32(episodeCaptures.First().Value);
var last = Convert.ToInt32(episodeCaptures.Last().Value); var last = Convert.ToInt32(episodeCaptures.Last().Value);
parsedIndexer.EpisodeNumbers = Enumerable.Range(first, last - first + 1).ToList(); result.EpisodeNumbers = Enumerable.Range(first, last - first + 1).ToList();
} }
else else
{ {
@ -206,7 +193,7 @@ namespace NzbDrone.Core
if (!String.IsNullOrWhiteSpace(matchCollection[0].Groups["extras"].Value)) if (!String.IsNullOrWhiteSpace(matchCollection[0].Groups["extras"].Value))
return null; return null;
parsedIndexer.FullSeason = true; result.FullSeason = true;
} }
} }
} }
@ -225,17 +212,17 @@ namespace NzbDrone.Core
airmonth = tempDay; airmonth = tempDay;
} }
parsedIndexer = new T result = new T
{ {
AirDate = new DateTime(airyear, airmonth, airday).Date, AirDate = new DateTime(airYear, airmonth, airday).Date,
}; };
} }
parsedIndexer.SeriesTitle = seriesName; result.SeriesTitle = seriesName;
Logger.Trace("Episode Parsed. {0}", parsedIndexer); Logger.Trace("Episode Parsed. {0}", result);
return parsedIndexer; return result;
} }
public static string ParseSeriesName(string title) public static string ParseSeriesName(string title)
@ -250,7 +237,7 @@ namespace NzbDrone.Core
return parseResult.CleanTitle; return parseResult.CleanTitle;
} }
internal static QualityModel ParseQuality(string name) private static QualityModel ParseQuality(string name)
{ {
Logger.Trace("Trying to parse quality for {0}", name); Logger.Trace("Trying to parse quality for {0}", name);
@ -399,7 +386,7 @@ namespace NzbDrone.Core
return result; return result;
} }
internal static LanguageType ParseLanguage(string title) private static LanguageType ParseLanguage(string title)
{ {
var lowerTitle = title.ToLower(); var lowerTitle = title.ToLower();
@ -484,40 +471,7 @@ namespace NzbDrone.Core
return NormalizeRegex.Replace(title, String.Empty).ToLower(); return NormalizeRegex.Replace(title, String.Empty).ToLower();
} }
public static long GetReportSize(string sizeString) public static string CleanupEpisodeTitle(string title)
{
var match = ReportSizeRegex.Matches(sizeString);
if (match.Count != 0)
{
var cultureInfo = new CultureInfo("en-US");
var value = Decimal.Parse(Regex.Replace(match[0].Groups["value"].Value, "\\,", ""), cultureInfo);
var unit = match[0].Groups["unit"].Value;
if (unit.Equals("MB", StringComparison.InvariantCultureIgnoreCase) || unit.Equals("MiB", StringComparison.InvariantCultureIgnoreCase))
return Convert.ToInt64(value * 1048576L);
if (unit.Equals("GB", StringComparison.InvariantCultureIgnoreCase) || unit.Equals("GiB", StringComparison.InvariantCultureIgnoreCase))
return Convert.ToInt64(value * 1073741824L);
}
return 0;
}
internal static string ParseHeader(string header)
{
foreach (var regex in HeaderRegex)
{
var match = regex.Matches(header);
if (match.Count != 0)
return match[0].Groups["nzbTitle"].Value.Trim();
}
return header;
}
internal static string CleanupEpisodeTitle(string title)
{ {
//this will remove (1),(2) from the end of multi part episodes. //this will remove (1),(2) from the end of multi part episodes.
return MultiPartCleanupRegex.Replace(title, string.Empty).Trim(); return MultiPartCleanupRegex.Replace(title, string.Empty).Trim();

@ -18,8 +18,8 @@ namespace NzbDrone.Test.Common.AutoMoq
[DebuggerStepThrough] [DebuggerStepThrough]
public class AutoMoqer public class AutoMoqer
{ {
internal readonly MockBehavior DefaultBehavior = MockBehavior.Default; public readonly MockBehavior DefaultBehavior = MockBehavior.Default;
internal Type ResolveType; public Type ResolveType;
private IUnityContainer container; private IUnityContainer container;
private IDictionary<Type, object> registeredMocks; private IDictionary<Type, object> registeredMocks;
@ -35,7 +35,7 @@ namespace NzbDrone.Test.Common.AutoMoq
} }
internal AutoMoqer(IUnityContainer container) public AutoMoqer(IUnityContainer container)
{ {
SetupAutoMoqer(container); SetupAutoMoqer(container);
} }
@ -73,7 +73,7 @@ namespace NzbDrone.Test.Common.AutoMoq
return mock; return mock;
} }
internal virtual void SetMock(Type type, Mock mock) public virtual void SetMock(Type type, Mock mock)
{ {
if (registeredMocks.ContainsKey(type) == false) if (registeredMocks.ContainsKey(type) == false)
registeredMocks.Add(type, mock); registeredMocks.Add(type, mock);

@ -10,7 +10,7 @@ using Moq;
namespace NzbDrone.Test.Common.AutoMoq.Unity namespace NzbDrone.Test.Common.AutoMoq.Unity
{ {
internal class AutoMockingBuilderStrategy : BuilderStrategy public class AutoMockingBuilderStrategy : BuilderStrategy
{ {
private readonly IUnityContainer _container; private readonly IUnityContainer _container;
private readonly MockRepository _mockFactory; private readonly MockRepository _mockFactory;

@ -8,7 +8,7 @@ using Microsoft.Practices.Unity.ObjectBuilder;
namespace NzbDrone.Test.Common.AutoMoq.Unity namespace NzbDrone.Test.Common.AutoMoq.Unity
{ {
internal class AutoMockingContainerExtension : UnityContainerExtension public class AutoMockingContainerExtension : UnityContainerExtension
{ {
private readonly IList<Type> registeredTypes = new List<Type>(); private readonly IList<Type> registeredTypes = new List<Type>();

@ -7,7 +7,7 @@ using System.Security.Principal;
namespace ServiceInstall namespace ServiceInstall
{ {
internal static class ServiceHelper public static class ServiceHelper
{ {
private static string NzbDroneExe private static string NzbDroneExe
{ {
@ -23,7 +23,7 @@ namespace ServiceInstall
return principal.IsInRole(WindowsBuiltInRole.Administrator); return principal.IsInRole(WindowsBuiltInRole.Administrator);
} }
internal static void Run(string arg) public static void Run(string arg)
{ {
if (!File.Exists(NzbDroneExe)) if (!File.Exists(NzbDroneExe))
{ {

@ -7,7 +7,7 @@ using System.Security.Principal;
namespace ServiceUninstall namespace ServiceUninstall
{ {
internal static class ServiceHelper public static class ServiceHelper
{ {
private static string NzbDroneExe private static string NzbDroneExe
{ {
@ -23,7 +23,7 @@ namespace ServiceUninstall
return principal.IsInRole(WindowsBuiltInRole.Administrator); return principal.IsInRole(WindowsBuiltInRole.Administrator);
} }
internal static void Run(string arg) public static void Run(string arg)
{ {
if (!File.Exists(NzbDroneExe)) if (!File.Exists(NzbDroneExe))
{ {

Loading…
Cancel
Save