mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-12 11:15:43 +02:00
Merge branch 'master' of git://github.com/kayone/NzbDrone
Conflicts: NzbDrone.Core.Test/ParserTest.cs
This commit is contained in:
commit
6dda51d0e7
@ -199,7 +199,7 @@ public void processResults_failed_download_should_not_check_the_rest()
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
|
||||
[TestCase(0)]
|
||||
[TestCase(-1)]
|
||||
[TestCase(-100)]
|
||||
|
@ -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 @@ public void no_grab_date(int offsetDays, bool hasEpisodes, bool ignored, Episode
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
[TestCase(1, false, false, EpisodeStatusType.Missing)]
|
||||
[TestCase(-2, false, false, EpisodeStatusType.Missing)]
|
||||
[TestCase(1, true, false, EpisodeStatusType.Ready)]
|
||||
@ -59,7 +58,6 @@ public void old_grab_date(int offsetDays, bool hasEpisodes, bool ignored,
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
[TestCase(1, false, false, EpisodeStatusType.Downloading)]
|
||||
[TestCase(-2, false, false, EpisodeStatusType.Downloading)]
|
||||
[TestCase(1, true, false, EpisodeStatusType.Downloading)]
|
||||
@ -83,7 +81,7 @@ public void recent_grab_date(int offsetDays, bool hasEpisodes, bool ignored,
|
||||
Assert.AreEqual(status, episode.Status);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
[TestCase(1, true, false, EpisodeStatusType.Ignored)]
|
||||
[TestCase(-2, true, false, EpisodeStatusType.Ignored)]
|
||||
[TestCase(1, true, true, EpisodeStatusType.Ready)]
|
||||
|
@ -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 @@ public void newzbin_rss_fetch()
|
||||
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 @@ public void custome_parser_partial_success(string title, int season, int episode
|
||||
Assert.AreEqual(quality, result.Quality.QualityType);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
[TestCase("Adventure.Inc.DVDRip.XviD-OSiTV")]
|
||||
public void custome_parser_full_parse(string title)
|
||||
{
|
||||
|
@ -205,18 +205,17 @@ public void IsQualityNeeded_file_not_in_history_should_be_downloaded()
|
||||
}
|
||||
|
||||
//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)
|
||||
{
|
||||
|
@ -17,7 +17,6 @@ public class ParserTest : TestBase
|
||||
* 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 @@ public void file_path_parse(string path, int season, int episode)
|
||||
}
|
||||
|
||||
|
||||
[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 @@ public void parsing_our_own_quality_enum()
|
||||
}
|
||||
}
|
||||
|
||||
[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 @@ public void parsing_our_own_quality_enum()
|
||||
[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 @@ public void episode_multipart_parse(string postTitle, string title, int season,
|
||||
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 @@ public void episode_daily_parse(string postTitle, string title, int year, int mo
|
||||
}
|
||||
|
||||
|
||||
[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 @@ public void full_season_release_parse(string postTitle, string title, int season
|
||||
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 @@ public void series_name_normalize(string parsedSeriesName, string seriesName)
|
||||
Assert.AreEqual(seriesName, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
[TestCase(@"c:\test\", @"c:\test")]
|
||||
[TestCase(@"c:\\test\\", @"c:\test")]
|
||||
[TestCase(@"C:\\Test\\", @"C:\Test")]
|
||||
@ -200,7 +198,7 @@ public void Normalize_Path(string dirty, string clean)
|
||||
Assert.AreEqual(clean, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
[TestCase("CaPitAl", "capital")]
|
||||
[TestCase("peri.od", "period")]
|
||||
[TestCase("this.^&%^**$%@#$!That", "thisthat")]
|
||||
@ -210,7 +208,7 @@ public void Normalize_Title(string dirty, string clean)
|
||||
Assert.AreEqual(clean, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
[TestCase("the")]
|
||||
[TestCase("and")]
|
||||
[TestCase("or")]
|
||||
@ -240,7 +238,7 @@ public void Normalize_removed_common_words(string word)
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
[TestCase("the")]
|
||||
[TestCase("and")]
|
||||
[TestCase("or")]
|
||||
|
@ -40,15 +40,14 @@ public void GetRootDirs()
|
||||
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>();
|
||||
rootDirProvider.Add(new RootDir { Path = path });
|
||||
@ -62,25 +61,26 @@ public void AddRootDir()
|
||||
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>();
|
||||
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 @@ public void empty_folder_path_throws()
|
||||
var mocker = new AutoMoqer();
|
||||
mocker.Resolve<RootDirProvider>().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<RootDirProvider>().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<RootDirProvider>().Update(new RootDir { Id = 2, Path = path });
|
||||
}
|
||||
}
|
||||
}
|
@ -259,7 +259,7 @@ public void IsInQueue_False_Error()
|
||||
mocker.Resolve<SabProvider>().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]")]
|
||||
|
Binary file not shown.
@ -5,6 +5,8 @@
|
||||
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 @@ public void successful_search(string title)
|
||||
result[0].SeriesName.Should().Be(title);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("The Simpsons")]
|
||||
[TestCase("Family Guy")]
|
||||
[TestCase("South Park")]
|
||||
@ -37,7 +37,7 @@ public void successful_title_lookup(string title)
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
|
||||
[TestCase(new object[] { "CAPITAL", "capital", true })]
|
||||
[TestCase(new object[] { "Something!!", "Something", true })]
|
||||
[TestCase(new object[] { "Simpsons 2000", "Simpsons", true })]
|
||||
@ -94,18 +94,15 @@ public void American_dad_fix()
|
||||
//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<List<TvdbEpisode>>(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 @@ public void American_dad_fix()
|
||||
}
|
||||
|
||||
//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();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -54,11 +54,11 @@ private static void InitializeApp()
|
||||
{
|
||||
BindKernel();
|
||||
|
||||
LogConfiguration.Setup();
|
||||
LogConfiguration.StartDbLogging();
|
||||
|
||||
Migrations.Run(Connection.MainConnectionString, true);
|
||||
|
||||
SetupDefaultQualityProfiles(_kernel.Get<IRepository>()); //Setup the default QualityProfiles on start-up
|
||||
_kernel.Get<QualityProvider>().SetupDefaultProfiles();
|
||||
|
||||
BindIndexers();
|
||||
BindJobs();
|
||||
@ -141,11 +141,11 @@ public static void DedicateToHost()
|
||||
{
|
||||
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 @@ public static void DedicateToHost()
|
||||
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 @@ private static void ShutDown()
|
||||
Logger.Info("Shutting down application.");
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
|
||||
private static void SetupDefaultQualityProfiles(IRepository repository)
|
||||
{
|
||||
var sd = new QualityProfile
|
||||
{
|
||||
Name = "SD",
|
||||
Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD },
|
||||
Cutoff = QualityTypes.SDTV
|
||||
};
|
||||
|
||||
var hd = new QualityProfile
|
||||
{
|
||||
Name = "HD",
|
||||
Allowed =
|
||||
new List<QualityTypes> { 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<QualityProfile>(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<QualityProfile>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Ninject;
|
||||
using Ninject.Activation;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
|
||||
@ -17,12 +18,13 @@ public static void Setup()
|
||||
|
||||
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 @@ private static void BindCustomLoggers()
|
||||
#endif
|
||||
var sonicTarget = CentralDispatch.NinjectKernel.Get<SubsonicTarget>();
|
||||
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();
|
||||
}
|
||||
|
@ -53,5 +53,39 @@ public virtual QualityProfile Find(int profileId)
|
||||
{
|
||||
return _repository.Single<QualityProfile>(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> { QualityTypes.SDTV, QualityTypes.DVD }, Cutoff = QualityTypes.SDTV };
|
||||
|
||||
var hd = new QualityProfile
|
||||
{
|
||||
Name = "HD",
|
||||
Allowed = new List<QualityTypes> { 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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 @@ public RootDirProvider(IRepository sonicRepo, SeriesProvider seriesProvider, Dis
|
||||
|
||||
public virtual List<RootDir> GetAll()
|
||||
{
|
||||
return _sonioRepo.All<RootDir>().ToList();
|
||||
return _repository.All<RootDir>().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<RootDir>(rootDirId);
|
||||
_repository.Delete<RootDir>(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<RootDir>(rootDirId);
|
||||
return _repository.Single<RootDir>(rootDirId);
|
||||
}
|
||||
|
||||
public List<String> GetUnmappedFolders(string path)
|
||||
|
@ -86,7 +86,7 @@ public virtual TvdbSeries GetSeries(int id, bool loadEpisodes)
|
||||
//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)
|
||||
|
@ -36,9 +36,6 @@ protected override void OnApplicationStarted()
|
||||
{
|
||||
base.OnApplicationStarted();
|
||||
|
||||
Logger.Info("NZBDrone Starting up.");
|
||||
CentralDispatch.DedicateToHost();
|
||||
|
||||
RegisterRoutes(RouteTable.Routes);
|
||||
//base.OnApplicationStarted();
|
||||
AreaRegistration.RegisterAllAreas();
|
||||
@ -48,6 +45,10 @@ protected override void OnApplicationStarted()
|
||||
|
||||
protected override IKernel CreateKernel()
|
||||
{
|
||||
LogConfiguration.Setup();
|
||||
Logger.Info("NZBDrone Starting up.");
|
||||
CentralDispatch.DedicateToHost();
|
||||
|
||||
var kernel = CentralDispatch.NinjectKernel;
|
||||
|
||||
// kernel.Bind<IRepository>().ToConstant(kernel.Get<IRepository>("LogDb"));
|
||||
|
@ -20,6 +20,8 @@
|
||||
<rules>
|
||||
|
||||
<logger name="IIS*" minlevel="Trace" writeTo="consoleTarget"/>
|
||||
<logger name="NzbDrone.Web.MvcApplication" minlevel="Trace" writeTo="consoleTarget"/>
|
||||
<logger name="NzbDrone.Core.CentralDispatch" minlevel="Trace" writeTo="consoleTarget"/>
|
||||
<logger name="Application" minlevel="Trace" writeTo="consoleTarget"/>
|
||||
<logger name="*" minlevel="Trace" writeTo="udpTarget"/>
|
||||
<logger name="*" minlevel="Off" writeTo="xmlFile">
|
||||
|
@ -49,7 +49,8 @@ internal static Process StartServer()
|
||||
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 @@ private static void PingServer(object sender, ElapsedEventArgs e)
|
||||
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 @@ private static void OnOutputDataReceived(object s, DataReceivedEventArgs e)
|
||||
e.Data.StartsWith("Request ended:") || e.Data == ("IncrementMessages called"))
|
||||
return;
|
||||
|
||||
if (e.Data.Contains(" NzbDrone."))
|
||||
{
|
||||
Console.WriteLine(e.Data);
|
||||
return;
|
||||
}
|
||||
|
||||
IISLogger.Trace(e.Data);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user