diff --git a/NzbDrone.Core.Test/EpisodeSearchJobTest.cs b/NzbDrone.Core.Test/EpisodeSearchJobTest.cs index 4c69d505c..1faab1de6 100644 --- a/NzbDrone.Core.Test/EpisodeSearchJobTest.cs +++ b/NzbDrone.Core.Test/EpisodeSearchJobTest.cs @@ -199,7 +199,7 @@ namespace NzbDrone.Core.Test } - [Test] + [TestCase(0)] [TestCase(-1)] [TestCase(-100)] diff --git a/NzbDrone.Core.Test/EpisodeStatusTest.cs b/NzbDrone.Core.Test/EpisodeStatusTest.cs index 56bca1510..62ae0d2b1 100644 --- a/NzbDrone.Core.Test/EpisodeStatusTest.cs +++ b/NzbDrone.Core.Test/EpisodeStatusTest.cs @@ -13,7 +13,7 @@ namespace NzbDrone.Core.Test // ReSharper disable InconsistentNaming public class EpisodeStatusTest : TestBase { - [Test] + [TestCase(1, false, false, EpisodeStatusType.NotAired)] [TestCase(-2, false, false, EpisodeStatusType.Missing)] [TestCase(1, true, false, EpisodeStatusType.Ready)] @@ -36,7 +36,6 @@ namespace NzbDrone.Core.Test } - [Test] [TestCase(1, false, false, EpisodeStatusType.Missing)] [TestCase(-2, false, false, EpisodeStatusType.Missing)] [TestCase(1, true, false, EpisodeStatusType.Ready)] @@ -59,7 +58,6 @@ namespace NzbDrone.Core.Test } - [Test] [TestCase(1, false, false, EpisodeStatusType.Downloading)] [TestCase(-2, false, false, EpisodeStatusType.Downloading)] [TestCase(1, true, false, EpisodeStatusType.Downloading)] @@ -83,7 +81,7 @@ namespace NzbDrone.Core.Test Assert.AreEqual(status, episode.Status); } - [Test] + [TestCase(1, true, false, EpisodeStatusType.Ignored)] [TestCase(-2, true, false, EpisodeStatusType.Ignored)] [TestCase(1, true, true, EpisodeStatusType.Ready)] diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 50ac36d16..fce620b40 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Test // ReSharper disable InconsistentNaming public class IndexerTests : TestBase { - [Test] + [TestCase("nzbsorg.xml", 0)] [TestCase("nzbsrus.xml", 6)] [TestCase("newzbin.xml", 1)] @@ -90,7 +90,7 @@ namespace NzbDrone.Core.Test ExceptionVerification.ExcpectedWarns(1); } - [Test] + [TestCase("Adventure.Inc.S03E19.DVDRip.XviD-OSiTV", 3, 19, QualityTypes.DVD)] public void custome_parser_partial_success(string title, int season, int episode, QualityTypes quality) { @@ -117,7 +117,7 @@ namespace NzbDrone.Core.Test Assert.AreEqual(quality, result.Quality.QualityType); } - [Test] + [TestCase("Adventure.Inc.DVDRip.XviD-OSiTV")] public void custome_parser_full_parse(string title) { diff --git a/NzbDrone.Core.Test/InventoryProvider_QualityNeededTest.cs b/NzbDrone.Core.Test/InventoryProvider_QualityNeededTest.cs index bfb286f42..ca03ab27c 100644 --- a/NzbDrone.Core.Test/InventoryProvider_QualityNeededTest.cs +++ b/NzbDrone.Core.Test/InventoryProvider_QualityNeededTest.cs @@ -205,18 +205,17 @@ namespace NzbDrone.Core.Test } //Should Download - [Test] - [TestCase(QualityTypes.SDTV, true, QualityTypes.HDTV, false, true)] - [TestCase(QualityTypes.DVD, true, QualityTypes.Bluray720p, true, true)] - [TestCase(QualityTypes.HDTV, false, QualityTypes.HDTV, true, true)] - [TestCase(QualityTypes.HDTV, false, QualityTypes.HDTV, false, false)] - [TestCase(QualityTypes.Bluray720p, true, QualityTypes.Bluray1080p, false, false)] - [TestCase(QualityTypes.HDTV, true, QualityTypes.Bluray720p, true, true)] - [TestCase(QualityTypes.Bluray1080p, true, QualityTypes.Bluray720p, true, false)] - [TestCase(QualityTypes.Bluray1080p, true, QualityTypes.Bluray720p, false, false)] - [TestCase(QualityTypes.Bluray1080p, false, QualityTypes.Bluray720p, true, false)] - [TestCase(QualityTypes.HDTV, false, QualityTypes.Bluray720p, true, true)] - [TestCase(QualityTypes.HDTV, true, QualityTypes.HDTV, false, false)] + [TestCase(QualityTypes.SDTV, true, QualityTypes.HDTV, false, true)] + [TestCase(QualityTypes.DVD, true, QualityTypes.Bluray720p, true, true)] + [TestCase(QualityTypes.HDTV, false, QualityTypes.HDTV, true, true)] + [TestCase(QualityTypes.HDTV, false, QualityTypes.HDTV, false, false)] + [TestCase(QualityTypes.Bluray720p, true, QualityTypes.Bluray1080p, false, false)] + [TestCase(QualityTypes.HDTV, true, QualityTypes.Bluray720p, true, true)] + [TestCase(QualityTypes.Bluray1080p, true, QualityTypes.Bluray720p, true, false)] + [TestCase(QualityTypes.Bluray1080p, true, QualityTypes.Bluray720p, false, false)] + [TestCase(QualityTypes.Bluray1080p, false, QualityTypes.Bluray720p, true, false)] + [TestCase(QualityTypes.HDTV, false, QualityTypes.Bluray720p, true, true)] + [TestCase(QualityTypes.HDTV, true, QualityTypes.HDTV, false, false)] public void Is_upgrade(QualityTypes fileQuality, bool isFileProper, QualityTypes reportQuality, bool isReportProper, bool excpected) { diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index 9ee4165a8..27e5a8309 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -17,7 +17,6 @@ namespace NzbDrone.Core.Test * Unreported.World.Chinas.Lost.Sons.WS.PDTV.XviD-FTP */ - [Test] [TestCase("Sonny.With.a.Chance.S02E15", "Sonny.With.a.Chance", 2, 15)] [TestCase("Two.and.a.Half.Me.103.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Me", 1, 3)] [TestCase("Two.and.a.Half.Me.113.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Me", 1, 13)] @@ -63,7 +62,6 @@ namespace NzbDrone.Core.Test } - [Test] [TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.DVD)] [TestCase("WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", QualityTypes.DVD)] [TestCase("WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.DVD)] @@ -123,7 +121,7 @@ namespace NzbDrone.Core.Test } } - [Test] + [Timeout(1000)] [TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", "WEEDS", 3, new[] { 1, 2, 3, 4, 5, 6 }, 6)] [TestCase("Two.and.a.Half.Men.103.104.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Men", 1, new[] { 3, 4 }, 2)] @@ -131,7 +129,7 @@ namespace NzbDrone.Core.Test [TestCase("The Borgias S01e01 e02 ShoHD On Demand 1080i DD5 1 ALANiS", "The Borgias", 1, new[] { 1, 2 }, 2)] [TestCase("Big Time Rush 1x01 to 10 480i DD2 0 Sianto", "Big Time Rush", 1, new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, 10)] [TestCase("White.Collar.2x04.2x05.720p.BluRay-FUTV", "White.Collar", 2, new[] { 4, 5 }, 2)] - [TestCase("Desperate.Housewives.S07E22E23.720p.HDTV.X264-DIMENSION", "Desperate.Housewives", 7, new[] { 22,23 }, 2)] + [TestCase("Desperate.Housewives.S07E22E23.720p.HDTV.X264-DIMENSION", "Desperate.Housewives", 7, new[] { 22, 23 }, 2)] //[Row("The.Kennedys.Part.1.and.Part.2.DSR.XviD-SYS", 1, new[] { 1, 2 })] [TestCase("S07E22 - 7x23 - And Lots of Security.. [HDTV].mkv", "", 7, new[] { 22, 23 }, 2)] [TestCase("Desparate Housewives - S07E22 - 7x23 - And Lots of Security.. [HDTV].mkv", "Desparate Housewives", 7, new[] { 22, 23 }, 2)] @@ -147,7 +145,7 @@ namespace NzbDrone.Core.Test Assert.AreEqual(count, result.EpisodeNumbers.Count); } - [Test] + [TestCase("Conan 2011 04 18 Emma Roberts HDTV XviD BFF", "Conan", 2011, 04, 18)] [TestCase("The Tonight Show With Jay Leno 2011 04 15 1080i HDTV DD5 1 MPEG2 TrollHD", "The Tonight Show With Jay Leno", 2011, 04, 15)] [TestCase("The.Daily.Show.2010.10.11.Johnny.Knoxville.iTouch-MW", "The.Daily.Show", 2010, 10, 11)] @@ -164,7 +162,7 @@ namespace NzbDrone.Core.Test } - [Test] + [TestCase("30.Rock.Season.04.HDTV.XviD-DIMENSION", "30.Rock", 4)] [TestCase("Parks.and.Recreation.S02.720p.x264-DIMENSION", "Parks.and.Recreation", 2)] [TestCase("The.Office.US.S03.720p.x264-DIMENSION", "The.Office.US", 3)] @@ -176,7 +174,7 @@ namespace NzbDrone.Core.Test Assert.AreEqual(0, result.EpisodeNumbers.Count); } - [Test] + [TestCase("Conan", "conan")] [TestCase("The Tonight Show With Jay Leno", "tonightshowwithjayleno")] [TestCase("The.Daily.Show", "dailyshow")] @@ -188,7 +186,7 @@ namespace NzbDrone.Core.Test Assert.AreEqual(seriesName, result); } - [Test] + [TestCase(@"c:\test\", @"c:\test")] [TestCase(@"c:\\test\\", @"c:\test")] [TestCase(@"C:\\Test\\", @"C:\Test")] @@ -200,7 +198,7 @@ namespace NzbDrone.Core.Test Assert.AreEqual(clean, result); } - [Test] + [TestCase("CaPitAl", "capital")] [TestCase("peri.od", "period")] [TestCase("this.^&%^**$%@#$!That", "thisthat")] @@ -210,7 +208,7 @@ namespace NzbDrone.Core.Test Assert.AreEqual(clean, result); } - [Test] + [TestCase("the")] [TestCase("and")] [TestCase("or")] @@ -240,7 +238,7 @@ namespace NzbDrone.Core.Test } - [Test] + [TestCase("the")] [TestCase("and")] [TestCase("or")] diff --git a/NzbDrone.Core.Test/RootDirProviderTest.cs b/NzbDrone.Core.Test/RootDirProviderTest.cs index 1ddf58866..796709dc2 100644 --- a/NzbDrone.Core.Test/RootDirProviderTest.cs +++ b/NzbDrone.Core.Test/RootDirProviderTest.cs @@ -40,15 +40,14 @@ namespace NzbDrone.Core.Test Assert.AreEqual(result.Count, 2); } - [Test] - public void AddRootDir() + [TestCase("D:\\TV Shows\\")] + [TestCase("//server//folder")] + public void AddRootDir(string path) { //Setup var mocker = new AutoMoqer(); mocker.SetConstant(MockLib.GetEmptyRepository()); - const string path = @"C:\TV\"; - //Act var rootDirProvider = mocker.Resolve(); rootDirProvider.Add(new RootDir { Path = path }); @@ -62,25 +61,26 @@ namespace NzbDrone.Core.Test Assert.AreEqual(path, rootDirs.First().Path); } - [Test] - public void UpdateRootDir() + + [TestCase("D:\\TV Shows\\")] + [TestCase("//server//folder")] + public void UpdateRootDir(string newPath) { //Setup var mocker = new AutoMoqer(); mocker.SetConstant(MockLib.GetEmptyRepository()); - const string path = @"C:\TV2"; //Act var rootDirProvider = mocker.Resolve(); rootDirProvider.Add(new RootDir { Path = @"C:\TV" }); - rootDirProvider.Update(new RootDir { Id = 1, Path = path }); + rootDirProvider.Update(new RootDir { Id = 1, Path = newPath }); //Assert var rootDirs = rootDirProvider.GetAll(); Assert.IsNotEmpty(rootDirs); rootDirs.Should().HaveCount(1); - Assert.AreEqual(path, rootDirs.First().Path); + Assert.AreEqual(newPath, rootDirs.First().Path); } [Test] @@ -144,5 +144,25 @@ namespace NzbDrone.Core.Test var mocker = new AutoMoqer(); mocker.Resolve().GetUnmappedFolders(""); } + + [TestCase("")] + [TestCase(null)] + [TestCase("BAD PATH")] + [ExpectedException(typeof(ArgumentException))] + public void invalid_folder_path_throws_on_add(string path) + { + var mocker = new AutoMoqer(); + mocker.Resolve().Add(new RootDir { Id = 0, Path = path }); + } + + [TestCase("")] + [TestCase(null)] + [TestCase("BAD PATH")] + [ExpectedException(typeof(ArgumentException))] + public void invalid_folder_path_throws_on_update(string path) + { + var mocker = new AutoMoqer(); + mocker.Resolve().Update(new RootDir { Id = 2, Path = path }); + } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/SabProviderTest.cs b/NzbDrone.Core.Test/SabProviderTest.cs index e0675fd89..0f7601ad0 100644 --- a/NzbDrone.Core.Test/SabProviderTest.cs +++ b/NzbDrone.Core.Test/SabProviderTest.cs @@ -259,7 +259,7 @@ namespace NzbDrone.Core.Test mocker.Resolve().IsInQueue(String.Empty); } - [Test] + [TestCase(1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, false, "My Series Name - 1x2 - My Episode Title [DVD]")] [TestCase(1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, true, "My Series Name - 1x2 - My Episode Title [DVD] [Proper]")] [TestCase(1, new[] { 2 }, "", QualityTypes.DVD, true, "My Series Name - 1x2 - [DVD] [Proper]")] diff --git a/NzbDrone.Core.Test/SeriesProviderTest.cs b/NzbDrone.Core.Test/SeriesProviderTest.cs index 48d7d8c1e..bd5086dd6 100644 Binary files a/NzbDrone.Core.Test/SeriesProviderTest.cs and b/NzbDrone.Core.Test/SeriesProviderTest.cs differ diff --git a/NzbDrone.Core.Test/TvDbProviderTest.cs b/NzbDrone.Core.Test/TvDbProviderTest.cs index be085c294..5dba84448 100644 --- a/NzbDrone.Core.Test/TvDbProviderTest.cs +++ b/NzbDrone.Core.Test/TvDbProviderTest.cs @@ -5,6 +5,8 @@ using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Providers; using NzbDrone.Core.Test.Framework; +using TvdbLib.Data; +using System.Collections.Generic; namespace NzbDrone.Core.Test { @@ -12,7 +14,6 @@ namespace NzbDrone.Core.Test // ReSharper disable InconsistentNaming public class TvDbProviderTest : TestBase { - [Test] [TestCase("The Simpsons")] [TestCase("Family Guy")] [TestCase("South Park")] @@ -24,7 +25,6 @@ namespace NzbDrone.Core.Test result[0].SeriesName.Should().Be(title); } - [Test] [TestCase("The Simpsons")] [TestCase("Family Guy")] [TestCase("South Park")] @@ -37,7 +37,7 @@ namespace NzbDrone.Core.Test } - [Test] + [TestCase(new object[] { "CAPITAL", "capital", true })] [TestCase(new object[] { "Something!!", "Something", true })] [TestCase(new object[] { "Simpsons 2000", "Simpsons", true })] @@ -94,18 +94,15 @@ namespace NzbDrone.Core.Test //act var result = tvdbProvider.GetSeries(73141, true); - var seasons = result.Episodes.Select(e => e.SeasonNumber) + var seasonsNumbers = result.Episodes.Select(e => e.SeasonNumber) .Distinct().ToList(); + var seasons = new List>(seasonsNumbers.Count); - - var seasons1 = result.Episodes.Where(e => e.SeasonNumber == 1).ToList(); - var seasons2 = result.Episodes.Where(e => e.SeasonNumber == 2).ToList(); - var seasons3 = result.Episodes.Where(e => e.SeasonNumber == 3).ToList(); - var seasons4 = result.Episodes.Where(e => e.SeasonNumber == 4).ToList(); - var seasons5 = result.Episodes.Where(e => e.SeasonNumber == 5).ToList(); - var seasons6 = result.Episodes.Where(e => e.SeasonNumber == 6).ToList(); - + foreach (var season in seasonsNumbers) + { + seasons.Insert(season, result.Episodes.Where(e => e.SeasonNumber == season).ToList()); + } foreach (var episode in result.Episodes) { @@ -113,19 +110,28 @@ namespace NzbDrone.Core.Test } //assert - seasons.Should().HaveCount(7); - seasons1.Should().HaveCount(23); - seasons2.Should().HaveCount(19); - seasons3.Should().HaveCount(16); - seasons4.Should().HaveCount(20); - seasons5.Should().HaveCount(18); + seasonsNumbers.Should().HaveCount(7); + seasons[1].Should().HaveCount(23); + seasons[2].Should().HaveCount(19); + seasons[3].Should().HaveCount(16); + seasons[4].Should().HaveCount(20); + seasons[5].Should().HaveCount(18); + + foreach (var season in seasons) + { + season.Should().OnlyHaveUniqueItems(); + } + + //Make sure no episode number is skipped + foreach (var season in seasons) + { + for (int i = 1; i < season.Count; i++) + { + season.Should().Contain(c => c.EpisodeNumber == i, "Can't find Episode S{0:00}E{1:00}", + season[0].SeasonNumber, i); + } + } - seasons1.Select(s => s.EpisodeNumber).Should().OnlyHaveUniqueItems(); - seasons2.Select(s => s.EpisodeNumber).Should().OnlyHaveUniqueItems(); - seasons3.Select(s => s.EpisodeNumber).Should().OnlyHaveUniqueItems(); - seasons4.Select(s => s.EpisodeNumber).Should().OnlyHaveUniqueItems(); - seasons5.Select(s => s.EpisodeNumber).Should().OnlyHaveUniqueItems(); - seasons6.Select(s => s.EpisodeNumber).Should().OnlyHaveUniqueItems(); } } diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index 50b96583c..c4a3c3dd5 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -54,11 +54,11 @@ namespace NzbDrone.Core { BindKernel(); - LogConfiguration.Setup(); + LogConfiguration.StartDbLogging(); Migrations.Run(Connection.MainConnectionString, true); - SetupDefaultQualityProfiles(_kernel.Get()); //Setup the default QualityProfiles on start-up + _kernel.Get().SetupDefaultProfiles(); BindIndexers(); BindJobs(); @@ -141,11 +141,11 @@ namespace NzbDrone.Core { try { - Logger.Debug("Attaching to parent process for automatic termination."); - var pc = new PerformanceCounter("Process", "Creating Process ID", - Process.GetCurrentProcess().ProcessName); - var pid = (int)pc.NextValue(); - var hostProcess = Process.GetProcessById(pid); + var pid = Convert.ToInt32(Environment.GetEnvironmentVariable("NZBDRONE_PID")); + + Logger.Debug("Attaching to parent process ({0}) for automatic termination.", pid); + + var hostProcess = Process.GetProcessById(Convert.ToInt32(pid)); hostProcess.EnableRaisingEvents = true; hostProcess.Exited += (delegate @@ -154,7 +154,7 @@ namespace NzbDrone.Core ShutDown(); }); - Logger.Debug("Successfully Attached to host. Process ID: {0}", pid); + Logger.Debug("Successfully Attached to host. Process [{0}]", hostProcess.ProcessName); } catch (Exception e) { @@ -167,55 +167,5 @@ namespace NzbDrone.Core Logger.Info("Shutting down application."); Process.GetCurrentProcess().Kill(); } - - private static void SetupDefaultQualityProfiles(IRepository repository) - { - var sd = new QualityProfile - { - Name = "SD", - Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }, - Cutoff = QualityTypes.SDTV - }; - - var hd = new QualityProfile - { - Name = "HD", - Allowed = - new List { QualityTypes.HDTV, QualityTypes.WEBDL, QualityTypes.Bluray720p }, - Cutoff = QualityTypes.HDTV - }; - - //Add or Update SD - Logger.Debug(String.Format("Checking for default QualityProfile: {0}", sd.Name)); - var sdDb = repository.Single(i => i.Name == sd.Name); - if (sdDb == null) - { - Logger.Debug(String.Format("Adding new default QualityProfile: {0}", sd.Name)); - repository.Add(sd); - } - - else - { - Logger.Debug(String.Format("Updating default QualityProfile: {0}", sd.Name)); - sd.QualityProfileId = sdDb.QualityProfileId; - repository.Update(sd); - } - - //Add or Update HD - Logger.Debug(String.Format("Checking for default QualityProfile: {0}", hd.Name)); - var hdDb = repository.Single(i => i.Name == hd.Name); - if (hdDb == null) - { - Logger.Debug(String.Format("Adding new default QualityProfile: {0}", hd.Name)); - repository.Add(hd); - } - - else - { - Logger.Debug(String.Format("Updating default QualityProfile: {0}", hd.Name)); - hd.QualityProfileId = hdDb.QualityProfileId; - repository.Update(hd); - } - } } } \ No newline at end of file diff --git a/NzbDrone.Core/Instrumentation/LogConfiguration.cs b/NzbDrone.Core/Instrumentation/LogConfiguration.cs index e57ddc52d..21b75225f 100644 --- a/NzbDrone.Core/Instrumentation/LogConfiguration.cs +++ b/NzbDrone.Core/Instrumentation/LogConfiguration.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using System.IO; using Ninject; +using Ninject.Activation; using NLog; using NLog.Config; @@ -17,12 +18,13 @@ namespace NzbDrone.Core.Instrumentation LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"), false); - LogManager.ConfigurationReloaded += ((s, e) => BindCustomLoggers()); - BindCustomLoggers(); + + LogManager.ConfigurationReloaded += ((s, e) => StartDbLogging()); } - private static void BindCustomLoggers() + public static void StartDbLogging() { + #if Release var exTarget = new ExceptioneerTarget(); LogManager.Configuration.AddTarget("Exceptioneer", exTarget); @@ -30,7 +32,7 @@ namespace NzbDrone.Core.Instrumentation #endif var sonicTarget = CentralDispatch.NinjectKernel.Get(); LogManager.Configuration.AddTarget("DbLogger", sonicTarget); - LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info, sonicTarget)); + LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, sonicTarget)); LogManager.Configuration.Reload(); } diff --git a/NzbDrone.Core/Providers/QualityProvider.cs b/NzbDrone.Core/Providers/QualityProvider.cs index 939c3832c..6a5ff341c 100644 --- a/NzbDrone.Core/Providers/QualityProvider.cs +++ b/NzbDrone.Core/Providers/QualityProvider.cs @@ -53,5 +53,39 @@ namespace NzbDrone.Core.Providers { return _repository.Single(q => q.QualityProfileId == profileId); } + + public virtual void SetupDefaultProfiles() + { + Logger.Info("Setting up default quality profiles"); + + var profiles = GetAllProfiles(); + + var sd = new QualityProfile { Name = "SD", Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }, Cutoff = QualityTypes.SDTV }; + + var hd = new QualityProfile + { + Name = "HD", + Allowed = new List { QualityTypes.HDTV, QualityTypes.WEBDL, QualityTypes.Bluray720p }, + Cutoff = QualityTypes.HDTV + }; + + //Add or Update SD + Logger.Debug(String.Format("Checking for default QualityProfile: {0}", sd.Name)); + var sdDb = profiles.Where(p => p.Name == sd.Name).FirstOrDefault(); + if (sdDb == null) + { + Logger.Debug(String.Format("Adding new default QualityProfile: {0}", sd.Name)); + Add(sd); + } + + //Add or Update HD + Logger.Debug(String.Format("Checking for default QualityProfile: {0}", hd.Name)); + var hdDb = profiles.Where(p => p.Name == hd.Name).FirstOrDefault(); + if (hdDb == null) + { + Logger.Debug(String.Format("Adding new default QualityProfile: {0}", hd.Name)); + Add(hd); + } + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/RootDirProvider.cs b/NzbDrone.Core/Providers/RootDirProvider.cs index 9c1e1aee9..2e0baa4df 100644 --- a/NzbDrone.Core/Providers/RootDirProvider.cs +++ b/NzbDrone.Core/Providers/RootDirProvider.cs @@ -11,15 +11,15 @@ namespace NzbDrone.Core.Providers { public class RootDirProvider { - private readonly IRepository _sonioRepo; + private readonly IRepository _repository; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private readonly DiskProvider _diskProvider; private readonly SeriesProvider _seriesProvider; - public RootDirProvider(IRepository sonicRepo, SeriesProvider seriesProvider, DiskProvider diskProvider) + public RootDirProvider(IRepository repository, SeriesProvider seriesProvider, DiskProvider diskProvider) { - _sonioRepo = sonicRepo; + _repository = repository; _diskProvider = diskProvider; _seriesProvider = seriesProvider; } @@ -28,27 +28,39 @@ namespace NzbDrone.Core.Providers public virtual List GetAll() { - return _sonioRepo.All().ToList(); + return _repository.All().ToList(); } public virtual int Add(RootDir rootDir) { - return Convert.ToInt32(_sonioRepo.Add(rootDir)); + ValidatePath(rootDir); + + return (int)_repository.Add(rootDir); } public virtual void Remove(int rootDirId) { - _sonioRepo.Delete(rootDirId); + _repository.Delete(rootDirId); } public virtual void Update(RootDir rootDir) { - _sonioRepo.Update(rootDir); + ValidatePath(rootDir); + + _repository.Update(rootDir); + } + + private static void ValidatePath(RootDir rootDir) + { + if (String.IsNullOrWhiteSpace(rootDir.Path) || !Path.IsPathRooted(rootDir.Path)) + { + throw new ArgumentException("Invalid path"); + } } public virtual RootDir GetRootDir(int rootDirId) { - return _sonioRepo.Single(rootDirId); + return _repository.Single(rootDirId); } public List GetUnmappedFolders(string path) diff --git a/NzbDrone.Core/Providers/TvDbProvider.cs b/NzbDrone.Core/Providers/TvDbProvider.cs index 7916f3b02..f965e2801 100644 --- a/NzbDrone.Core/Providers/TvDbProvider.cs +++ b/NzbDrone.Core/Providers/TvDbProvider.cs @@ -86,7 +86,7 @@ namespace NzbDrone.Core.Providers //Fix American Dad's scene gongshow if (result != null && result.Id == 73141) { - var seasonOneEpisodeCount = result.Episodes.Where(e => e.SeasonNumber == 0).Count(); + var seasonOneEpisodeCount = result.Episodes.Where(e => e.SeasonNumber == 1).Count(); var seasonOneId = result.Episodes.Where(e => e.SeasonNumber == 1).First().SeasonId; foreach (var episode in result.Episodes) diff --git a/NzbDrone.Web/Global.asax.cs b/NzbDrone.Web/Global.asax.cs index d23b6085a..182f1d62a 100644 --- a/NzbDrone.Web/Global.asax.cs +++ b/NzbDrone.Web/Global.asax.cs @@ -36,9 +36,6 @@ namespace NzbDrone.Web { base.OnApplicationStarted(); - Logger.Info("NZBDrone Starting up."); - CentralDispatch.DedicateToHost(); - RegisterRoutes(RouteTable.Routes); //base.OnApplicationStarted(); AreaRegistration.RegisterAllAreas(); @@ -48,6 +45,10 @@ namespace NzbDrone.Web protected override IKernel CreateKernel() { + LogConfiguration.Setup(); + Logger.Info("NZBDrone Starting up."); + CentralDispatch.DedicateToHost(); + var kernel = CentralDispatch.NinjectKernel; // kernel.Bind().ToConstant(kernel.Get("LogDb")); diff --git a/NzbDrone.Web/log.config b/NzbDrone.Web/log.config index 8abd77ebc..74a10037b 100644 --- a/NzbDrone.Web/log.config +++ b/NzbDrone.Web/log.config @@ -20,6 +20,8 @@ + + diff --git a/NzbDrone/IISController.cs b/NzbDrone/IISController.cs index 23b7c9e91..7721d5262 100644 --- a/NzbDrone/IISController.cs +++ b/NzbDrone/IISController.cs @@ -49,7 +49,8 @@ namespace NzbDrone IISProcess.ErrorDataReceived += (OnErrorDataReceived); //Set Variables for the config file. - Environment.SetEnvironmentVariable("NZBDRONE_PATH", Config.ProjectRoot); + IISProcess.StartInfo.EnvironmentVariables.Add("NZBDRONE_PATH", Config.ProjectRoot); + IISProcess.StartInfo.EnvironmentVariables.Add("NZBDRONE_PID", Process.GetCurrentProcess().Id.ToString()); try { @@ -120,7 +121,7 @@ namespace NzbDrone try { var response = new WebClient().DownloadString(AppUrl + "/health"); - + if (!response.Contains("OK")) { throw new ServerException("Health services responded with an invalid response."); @@ -148,6 +149,12 @@ namespace NzbDrone e.Data.StartsWith("Request ended:") || e.Data == ("IncrementMessages called")) return; + if (e.Data.Contains(" NzbDrone.")) + { + Console.WriteLine(e.Data); + return; + } + IISLogger.Trace(e.Data); }