From e4f01ae0d449867d656793b827e20e2a42e470a5 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 13 Sep 2011 19:25:33 -0700 Subject: [PATCH] Size is now parsed for each item in the feed. QualityType added to database to allow saving of size limits. Fluent now uses longs for multiplication, to ensure it doesn't overflow. --- .../Files/RSS/SizeParsing/newzbin.xml | 82 ++++++++++++++ .../Files/RSS/SizeParsing/nzbmatrix.xml | 23 ++++ .../Files/RSS/SizeParsing/nzbsorg.xml | 27 +++++ .../Files/RSS/SizeParsing/nzbsrus.xml | 23 ++++ NzbDrone.Core.Test/IndexerTests.cs | 70 +++++++++++- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 13 +++ NzbDrone.Core.Test/ParserTest.cs | 13 +++ NzbDrone.Core.Test/QualityTypeProviderTest.cs | 105 ++++++++++++++++++ NzbDrone.Core/CentralDispatch.cs | 1 + .../Datastore/Migrations/Migration20110909.cs | 8 ++ NzbDrone.Core/Fluent.cs | 4 +- NzbDrone.Core/Model/EpisodeParseResult.cs | 2 + NzbDrone.Core/NzbDrone.Core.csproj | 3 + NzbDrone.Core/Parser.cs | 22 ++++ NzbDrone.Core/Providers/Indexer/Newzbin.cs | 4 + NzbDrone.Core/Providers/Indexer/NzbMatrix.cs | 12 ++ NzbDrone.Core/Providers/Indexer/NzbsOrg.cs | 12 ++ NzbDrone.Core/Providers/Indexer/NzbsRUs.cs | 13 +++ .../Providers/QualityTypeProvider.cs | 68 ++++++++++++ .../Repository/Quality/QualityType.cs | 24 ++++ NzbDrone.Web/Views/Series/Details.cshtml | 1 - 21 files changed, 524 insertions(+), 6 deletions(-) create mode 100644 NzbDrone.Core.Test/Files/RSS/SizeParsing/newzbin.xml create mode 100644 NzbDrone.Core.Test/Files/RSS/SizeParsing/nzbmatrix.xml create mode 100644 NzbDrone.Core.Test/Files/RSS/SizeParsing/nzbsorg.xml create mode 100644 NzbDrone.Core.Test/Files/RSS/SizeParsing/nzbsrus.xml create mode 100644 NzbDrone.Core.Test/QualityTypeProviderTest.cs create mode 100644 NzbDrone.Core/Providers/QualityTypeProvider.cs create mode 100644 NzbDrone.Core/Repository/Quality/QualityType.cs diff --git a/NzbDrone.Core.Test/Files/RSS/SizeParsing/newzbin.xml b/NzbDrone.Core.Test/Files/RSS/SizeParsing/newzbin.xml new file mode 100644 index 000000000..220f672d2 --- /dev/null +++ b/NzbDrone.Core.Test/Files/RSS/SizeParsing/newzbin.xml @@ -0,0 +1,82 @@ + + + + www.newzbin.com (reports) + http://www.newzbin.com/browse/category/p/tv/ + Newzbin Reports Feed + Mon, 25 Apr 2011 16:08:24 GMT + 42 + www.newzbin.com - Usenet Search + Copyright (c) 2002 - 2007 Newzbin Limited. All Rights Reserved. + + http://www.newzbin.com/m/i/logo/newzbinv3.png + http://www.newzbin.com/browse/category/p/tv/ + www.newzbin.com + Visit Newzbin.com - The Ultimate In Usenet Indexing + + + Rookie Blue - 1x10 - Big Nickel + http://www.newzbin.com/browse/post/6076287/ + http://www.newzbin.com/browse/post/6076287/ + http://www.newzbin.com/browse/post/6076287/#CommentsPH + + +
  • + ID: 6076287 + (Bookmark) + (NZB) + (NFO) + (More Info) + (Size: 1,235.6MB) +
  • +
  • + Attributes: + Category - TV + | Video Source - TV Cap, HDTV | Video Format - x264, 720p | Video Genre - Action/Adv, Crime, Drama, Family | Language - English, German +
  • +
  • Groups: alt.binaries.illuminaten
  • +
  • Poster: AuToMaTiC <AuTo@Illuminatenboard.org>
  • +
  • PostDate: Sunday 06 Mar 2011, 01:05PM PDT
  • + ]]> +
    + 6076287 + TV + + TV Cap + HDTV + x264 + 720p + Action/Adv + Crime + Drama + Family + English + German + + + alt.binaries.illuminaten + + Report is complete + http://www.tvrage.com/Rookie_Blue/episodes/1064943067/1x10/ + + 373966350 + tvp-rookieblue-s01e10-720p.nfo + http://www.newzbin.com/nfo/view/txt/373966350/ + + http://www.newzbin.com/browse/post/6076287/nzb/ + AuToMaTiC <AuTo@Illuminatenboard.org> + 1295652290 + Sun, 06 Mar 2011 21:05:58 GMT + + 2 + 0 + + + Mon, 25 Apr 2011 11:55:04 GMT +
    +
    +
    \ No newline at end of file diff --git a/NzbDrone.Core.Test/Files/RSS/SizeParsing/nzbmatrix.xml b/NzbDrone.Core.Test/Files/RSS/SizeParsing/nzbmatrix.xml new file mode 100644 index 000000000..8ff043ef0 --- /dev/null +++ b/NzbDrone.Core.Test/Files/RSS/SizeParsing/nzbmatrix.xml @@ -0,0 +1,23 @@ + + + + NZBMatrix.com RSS 2.0 + en + NZBMatrix + NZBMatrix.com RSS Feed - Usenet + http://nzbmatrix.com + + Copyright 2011 NZBMatrix + Wed, 14 Sep 2011 02:18:04 +0200 + + House S04E11 720p HDTV x264 BAWLS + http://nzbmatrix.com/nzb-details.php?id=914522&hit=1 + http://nzbmatrix.com/nzb-details.php?id=914522&hit=1 + Name: House S04E11 FRENCH 720p HDTV x264 BAWLS
    Category: TV: HD
    Size: 1.24 GB
    Added: 2011-04-25 15:06:58
    Group: alt.binaries.multimedia
    NFO: View NFO ]]>
    + TV: HD + tv.hd + 41 + +
    +
    +
    \ No newline at end of file diff --git a/NzbDrone.Core.Test/Files/RSS/SizeParsing/nzbsorg.xml b/NzbDrone.Core.Test/Files/RSS/SizeParsing/nzbsorg.xml new file mode 100644 index 000000000..7060086f1 --- /dev/null +++ b/NzbDrone.Core.Test/Files/RSS/SizeParsing/nzbsorg.xml @@ -0,0 +1,27 @@ + + + + All Categories - NZBs(dot)ORG RSS Feed + http://nzbs.org/index.php?&catid= + All Categories feed for NZBs(dot)ORG + en-us + + Shameless.S08E17.720p.HDTV.x264-BiA + + Wed, 14 Sep 2011 02:14:09 +0000 + TV-x264 + http://nzbs.org/index.php?action=view&nzbid=750588 + Category: TV-x264
    Size: 1.67 GB
    Files: 44 (8 pars)
    Group: a.b.teevee
    .NFO: View NFO
    Ext. Link: http://www.tvrage.com/shows/id-5162
    Posted: Wed September 14th 00:00:15 UTC
    Add to My NZBs
    Download NZB
    ]]>
    + http://nzbs.org/index.php?action=view&nzbid=750588 + 750588 + + TV-x264 + http://nzbs.org/index.php?action=getnzb&nzbid=750588&i=9695&h=92653d4053a322e123dbbb3da887c5c5 + + 1788245756 + Wed, 14 Sep 2011 00:00:15 +0000 + + http://www.tvrage.com/shows/id-5162 +
    +
    +
    \ No newline at end of file diff --git a/NzbDrone.Core.Test/Files/RSS/SizeParsing/nzbsrus.xml b/NzbDrone.Core.Test/Files/RSS/SizeParsing/nzbsrus.xml new file mode 100644 index 000000000..623d20f5d --- /dev/null +++ b/NzbDrone.Core.Test/Files/RSS/SizeParsing/nzbsrus.xml @@ -0,0 +1,23 @@ + + + + NZBsRus.com + This is the NZBs'R'US RSS feed. + http://www.nzbsrus.com + en-US + 5 + + + Shameless.S08E17.720p.HDTV.x264-BiA + Wed, 14 Sep 2011 01:06:49 am + TV - HD + http://www.nzbsrus.com/nzbdownload_rss.php/457967/68614/4182562f71f29cd36b9e7495d00abcff/ + + Size 1.67 GiB (42 files) + Files: 34 + Par2s: 8 + + + + + \ No newline at end of file diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 303167f26..8c077e1a4 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -316,8 +316,72 @@ namespace NzbDrone.Core.Test result.Should().Be(clean); } + [Test] + public void size_newzbin() + { + //Setup + var mocker = new AutoMoqer(); + + mocker.GetMock() + .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) + .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\newzbin.xml")); + + //Act + var parseResults = mocker.Resolve().FetchRss(); + + parseResults.Should().HaveCount(1); + parseResults[0].Size.Should().Be(1295620506); + } + + [Test] + public void size_nzbmatrix() + { + //Setup + var mocker = new AutoMoqer(); + + mocker.GetMock() + .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) + .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbmatrix.xml")); + + //Act + var parseResults = mocker.Resolve().FetchRss(); + + parseResults.Should().HaveCount(1); + parseResults[0].Size.Should().Be(1331439862); + } + + [Test] + public void size_nzbsorg() + { + //Setup + var mocker = new AutoMoqer(); + + mocker.GetMock() + .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) + .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbsorg.xml")); + + //Act + var parseResults = mocker.Resolve().FetchRss(); + + parseResults.Should().HaveCount(1); + parseResults[0].Size.Should().Be(1793148846); + } + + [Test] + public void size_nzbsrus() + { + //Setup + var mocker = new AutoMoqer(); + + mocker.GetMock() + .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) + .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbsrus.xml")); + + //Act + var parseResults = mocker.Resolve().FetchRss(); + + parseResults.Should().HaveCount(1); + parseResults[0].Size.Should().Be(1793148846); + } } - - - } diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index ea245f194..5fab03992 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -90,6 +90,7 @@ + @@ -156,6 +157,18 @@ Always + + Always + + + Always + + + Always + + + Always + Always diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index a3a38c165..64f407489 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -338,5 +338,18 @@ namespace NzbDrone.Core.Test result.SeasonNumber.Should().Be(seasonNumber); result.FullSeason.Should().BeTrue(); } + + [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); + } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/QualityTypeProviderTest.cs b/NzbDrone.Core.Test/QualityTypeProviderTest.cs new file mode 100644 index 000000000..ab7771da6 --- /dev/null +++ b/NzbDrone.Core.Test/QualityTypeProviderTest.cs @@ -0,0 +1,105 @@ +// ReSharper disable RedundantUsingDirective +using System; +using System.Collections.Generic; +using AutoMoq; +using FizzWare.NBuilder; +using FluentAssertions; +using Moq; +using NUnit.Framework; +using NzbDrone.Core.Providers; +using NzbDrone.Core.Repository; +using NzbDrone.Core.Repository.Quality; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test +{ + [TestFixture] + // ReSharper disable InconsistentNaming + public class QualityTypeProviderTest : TestBase + { + [Test] + public void SetupDefault_should_add_six_profiles() + { + var mocker = new AutoMoqer(); + var db = MockLib.GetEmptyDatabase(); + mocker.SetConstant(db); + + //Act + mocker.Resolve().SetupDefault(); + + //Assert + var types = mocker.Resolve().All(); + + types.Should().HaveCount(6); + types.Should().Contain(e => e.Name == "SDTV" && e.QualityTypeId == 1); + types.Should().Contain(e => e.Name == "DVD" && e.QualityTypeId == 2); + types.Should().Contain(e => e.Name == "HDTV" && e.QualityTypeId == 4); + types.Should().Contain(e => e.Name == "WEBDL" && e.QualityTypeId == 5); + types.Should().Contain(e => e.Name == "Bluray720p" && e.QualityTypeId == 6); + types.Should().Contain(e => e.Name == "Bluray1080p" && e.QualityTypeId == 7); + } + + [Test] + public void SetupDefault_already_exists() + { + var mocker = new AutoMoqer(); + var db = MockLib.GetEmptyDatabase(); + mocker.SetConstant(db); + + var fakeQualityType = Builder.CreateNew() + .Build(); + + db.Insert(fakeQualityType); + + //Act + mocker.Resolve().SetupDefault(); + + //Assert + var types = mocker.Resolve().All(); + + types.Should().HaveCount(1); + } + + [Test] + public void GetList_single_quality_type() + { + var mocker = new AutoMoqer(); + var db = MockLib.GetEmptyDatabase(); + mocker.SetConstant(db); + + var fakeQualityTypes = Builder.CreateListOfSize(6) + .Build(); + + var ids = new List { 1 }; + + db.InsertMany(fakeQualityTypes); + + //Act + var result = mocker.Resolve().GetList(ids); + + //Assert + result.Should().HaveCount(ids.Count); + } + + [Test] + public void GetList_multiple_quality_type() + { + var mocker = new AutoMoqer(); + var db = MockLib.GetEmptyDatabase(); + mocker.SetConstant(db); + + var fakeQualityTypes = Builder.CreateListOfSize(6) + .Build(); + + var ids = new List { 1, 2 }; + + db.InsertMany(fakeQualityTypes); + + //Act + var result = mocker.Resolve().GetList(ids); + + //Assert + result.Should().HaveCount(ids.Count); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index 4a0860b39..c255d1062 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -61,6 +61,7 @@ namespace NzbDrone.Core LogConfiguration.StartDbLogging(); _kernel.Get().SetupDefaultProfiles(); + _kernel.Get().SetupDefault(); BindExternalNotifications(); BindIndexers(); diff --git a/NzbDrone.Core/Datastore/Migrations/Migration20110909.cs b/NzbDrone.Core/Datastore/Migrations/Migration20110909.cs index 9e7f7de76..13a83e17c 100644 --- a/NzbDrone.Core/Datastore/Migrations/Migration20110909.cs +++ b/NzbDrone.Core/Datastore/Migrations/Migration20110909.cs @@ -12,6 +12,14 @@ namespace NzbDrone.Core.Datastore.Migrations { Database.AddColumn("Series", "Runtime", DbType.Int32, ColumnProperty.Null); Database.AddColumn("Series", "BannerUrl", DbType.String, ColumnProperty.Null); + + Database.AddTable("QualityTypes", new[] + { + new Column("QualityTypeId", DbType.Int32, ColumnProperty.PrimaryKey), + new Column("Name", DbType.String, ColumnProperty.NotNull), + new Column("MinSize", DbType.Int64, ColumnProperty.NotNull), + new Column("MaxSize", DbType.Int64, ColumnProperty.NotNull) + }); } public override void Down() diff --git a/NzbDrone.Core/Fluent.cs b/NzbDrone.Core/Fluent.cs index 5b06b482d..cd5ce56db 100644 --- a/NzbDrone.Core/Fluent.cs +++ b/NzbDrone.Core/Fluent.cs @@ -21,12 +21,12 @@ namespace NzbDrone.Core public static Int64 Megabytes(this int megabytes) { - return megabytes * 1048576; + return megabytes * 1048576L; } public static Int64 Gigabytes(this int gigabytes) { - return gigabytes * 1073741824; + return gigabytes * 1073741824L; } } } diff --git a/NzbDrone.Core/Model/EpisodeParseResult.cs b/NzbDrone.Core/Model/EpisodeParseResult.cs index 4a4fae7b2..a0de81236 100644 --- a/NzbDrone.Core/Model/EpisodeParseResult.cs +++ b/NzbDrone.Core/Model/EpisodeParseResult.cs @@ -30,6 +30,8 @@ namespace NzbDrone.Core.Model public bool FullSeason { get; set; } + public long Size { get; set; } + public override string ToString() { if (AirDate != null && EpisodeNumbers == null) diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 51de3be66..88f60d607 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -211,6 +211,7 @@ + @@ -276,6 +277,7 @@ + @@ -320,6 +322,7 @@ + diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index bc48342ea..a9fa7b70e 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -54,6 +54,9 @@ 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|\<|\>|\?|\*|\:|\||""", RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex ReportSizeRegex = new Regex(@"(?\d+\.\d{1,2}|\d+\,\d+\.\d{1,2})\W?(?GB|MB|GiB|MiB)", + RegexOptions.IgnoreCase | RegexOptions.Compiled); + /// /// Parses a file path into list of episodes it contains @@ -392,5 +395,24 @@ namespace NzbDrone.Core // Return char and concat substring. return char.ToUpper(s[0]) + s.Substring(1); } + + public static long GetReportSize(string sizeString) + { + var match = ReportSizeRegex.Matches(sizeString); + + if (match.Count != 0) + { + var value = Convert.ToDecimal(Regex.Replace(match[0].Groups["value"].Value, "\\,", "")); + + 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; + } } } diff --git a/NzbDrone.Core/Providers/Indexer/Newzbin.cs b/NzbDrone.Core/Providers/Indexer/Newzbin.cs index ae99761d4..a5e33a212 100644 --- a/NzbDrone.Core/Providers/Indexer/Newzbin.cs +++ b/NzbDrone.Core/Providers/Indexer/Newzbin.cs @@ -96,6 +96,10 @@ namespace NzbDrone.Core.Providers.Indexer 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); } return currentResult; } diff --git a/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs b/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs index e9799e6c8..ac9f40ff8 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; using System.ServiceModel.Syndication; +using System.Text.RegularExpressions; using Ninject; +using NzbDrone.Core.Model; using NzbDrone.Core.Model.Search; using NzbDrone.Core.Providers.Core; @@ -67,5 +69,15 @@ namespace NzbDrone.Core.Providers.Indexer return searchUrls; } + protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult) + { + 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); + } + return currentResult; + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/Indexer/NzbsOrg.cs b/NzbDrone.Core/Providers/Indexer/NzbsOrg.cs index cb6acef3c..14001438a 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbsOrg.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbsOrg.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; using System.ServiceModel.Syndication; +using System.Text.RegularExpressions; using Ninject; +using NzbDrone.Core.Model; using NzbDrone.Core.Model.Search; using NzbDrone.Core.Providers.Core; @@ -65,5 +67,15 @@ namespace NzbDrone.Core.Providers.Indexer return searchUrls; } + protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult) + { + if (currentResult != null) + { + var sizeString = Regex.Match(item.Summary.Text, @">\d+\.\d{1,2} \w{2}", RegexOptions.IgnoreCase).Value; + + currentResult.Size = Parser.GetReportSize(sizeString); + } + return currentResult; + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs b/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs index d09d2b627..c8bd86294 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; using System.ServiceModel.Syndication; +using System.Text.RegularExpressions; using Ninject; +using NzbDrone.Core.Model; using NzbDrone.Core.Model.Search; using NzbDrone.Core.Providers.Core; @@ -41,5 +43,16 @@ namespace NzbDrone.Core.Providers.Indexer { return new List(); } + + protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult) + { + if (currentResult != null) + { + var sizeString = Regex.Match(item.Summary.Text, @"\d+\.\d{1,2} \w{3}", RegexOptions.IgnoreCase).Value; + + currentResult.Size = Parser.GetReportSize(sizeString); + } + return currentResult; + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/QualityTypeProvider.cs b/NzbDrone.Core/Providers/QualityTypeProvider.cs new file mode 100644 index 000000000..ae746723d --- /dev/null +++ b/NzbDrone.Core/Providers/QualityTypeProvider.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NLog; +using NzbDrone.Core.Repository.Quality; +using PetaPoco; + +namespace NzbDrone.Core.Providers +{ + public class QualityTypeProvider + { + private readonly IDatabase _database; + + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + + public QualityTypeProvider(IDatabase database) + { + _database = database; + } + + public virtual void Update(QualityType qualityType) + { + _database.Update(qualityType); + } + + public virtual void UpdateAll(List qualityTypes) + { + _database.UpdateMany(qualityTypes); + } + + public virtual List All() + { + return _database.Fetch(); + } + + public virtual QualityType Get(int qualityTypeId) + { + return _database.Single(qualityTypeId); + } + + public virtual List GetList(List qualityTypeIds) + { + var queryParams = String.Join(", ", qualityTypeIds); + var query = String.Format("WHERE QualityTypeId IN ({0})", queryParams); + + return _database.Fetch(query); + } + + public virtual void SetupDefault() + { + if (All().Count != 0) + return; + + Logger.Info("Setting up default quality types"); + + var qualityTypes = new List(); + qualityTypes.Add(new QualityType { QualityTypeId = 1, Name = "SDTV", MinSize = 0, MaxSize = 10.Gigabytes() }); + qualityTypes.Add(new QualityType { QualityTypeId = 2, Name = "DVD", MinSize = 0, MaxSize = 10.Gigabytes() }); + qualityTypes.Add(new QualityType { QualityTypeId = 4, Name = "HDTV", MinSize = 0, MaxSize = 10.Gigabytes() }); + qualityTypes.Add(new QualityType { QualityTypeId = 5, Name = "WEBDL", MinSize = 0, MaxSize = 10.Gigabytes() }); + qualityTypes.Add(new QualityType { QualityTypeId = 6, Name = "Bluray720p", MinSize = 0, MaxSize = 10.Gigabytes() }); + qualityTypes.Add(new QualityType { QualityTypeId = 7, Name = "Bluray1080p", MinSize = 0, MaxSize = 10.Gigabytes() }); + + _database.InsertMany(qualityTypes); + } + } +} diff --git a/NzbDrone.Core/Repository/Quality/QualityType.cs b/NzbDrone.Core/Repository/Quality/QualityType.cs new file mode 100644 index 000000000..037e640e4 --- /dev/null +++ b/NzbDrone.Core/Repository/Quality/QualityType.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using PetaPoco; + +namespace NzbDrone.Core.Repository.Quality +{ + [TableName("QualityTypes")] + [PrimaryKey("QualityTypeId", autoIncrement = false)] + public class QualityType + { + public int QualityTypeId { get; set; } + public string Name { get; set; } + public long MinSize { get; set; } + public long MaxSize { get; set; } + + public override string ToString() + { + return Name; + } + } +} \ No newline at end of file diff --git a/NzbDrone.Web/Views/Series/Details.cshtml b/NzbDrone.Web/Views/Series/Details.cshtml index b3302bcf0..70e18465e 100644 --- a/NzbDrone.Web/Views/Series/Details.cshtml +++ b/NzbDrone.Web/Views/Series/Details.cshtml @@ -81,7 +81,6 @@ #banner-container { - width: 758px; height: 140px; padding: 0px;