Merge branch 'release-group'

pull/6/head
Mark McDowall 13 years ago
commit 39aa5065bb

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xml:lang="en-GB"
xmlns:report="http://www.newzbin.com/DTD/2007/feeds/report/">
xmlns:report="http://www.newzbin2.es/DTD/2007/feeds/report/">
<channel>
<title>www.newzbin.com (reports)</title>
<link>http://www.newzbin.com/browse/category/p/tv/</link>
@ -63,7 +63,7 @@ xmlns:report="http://www.newzbin.com/DTD/2007/feeds/report/">
<report:moreinfo>http://www.tvrage.com/Rookie_Blue/episodes/1064943067/1x10/</report:moreinfo>
<report:nfo>
<report:fileid>373966350</report:fileid>
<report:filename>tvp-rookieblue-s01e10-720p.nfo</report:filename>
<report:filename>rookieblue-s01e10-720p-tvp.nfo</report:filename>
<report:link>http://www.newzbin.com/nfo/view/txt/373966350/</report:link>
</report:nfo>
<report:nzb>http://www.newzbin.com/browse/post/6076287/nzb/</report:nzb>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xml:lang="en-GB"
xmlns:report="http://www.newzbin.com/DTD/2007/feeds/report/">
xmlns:report="http://www.newzbin2.es/DTD/2007/feeds/report/">
<channel>
<title>www.newzbin.com (reports)</title>
<link>http://www.newzbin.com/browse/category/p/tv/</link>

@ -692,5 +692,21 @@ namespace NzbDrone.Core.Test
episodeParseResult.NzbInfoUrl.Should().Contain(expectedString);
}
}
[Test]
public void releaseGroup_should_use_nfo_filename_for_newzbin()
{
WithConfiguredIndexers();
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\newzbin.xml"));
//Act
var parseResults = Mocker.Resolve<Newzbin>().FetchRss();
parseResults.Should().HaveCount(1);
parseResults[0].ReleaseGroup.Should().Be("tvp");
}
}
}

@ -113,6 +113,7 @@
<Compile Include="JobTests\RecentBacklogSearchJobTest.cs" />
<Compile Include="ProviderTests\ConfigProviderTests\ConfigCachingFixture.cs" />
<Compile Include="ProviderTests\BannerProviderTest.cs" />
<Compile Include="ProviderTests\DecisionEngineTests\AllowedReleaseGroupSpecificationFixture.cs" />
<Compile Include="ProviderTests\Metadata\Xbmc_ForEpisodeFile_Fixture.cs" />
<Compile Include="ProviderTests\Metadata\Xbmc_ForSeries_Fixture.cs" />
<Compile Include="ProviderTests\SearchHistoryProviderTest.cs" />

@ -185,7 +185,6 @@ namespace NzbDrone.Core.Test
{
var qualityEnums = Enum.GetValues(typeof(QualityTypes));
foreach (var qualityEnum in qualityEnums)
{
var fileName = String.Format("My series S01E01 [{0}]", qualityEnum);
@ -276,8 +275,6 @@ namespace NzbDrone.Core.Test
result.Should().Be(seriesName);
}
[TestCase("CaPitAl", "capital")]
[TestCase("peri.od", "period")]
[TestCase("this.^&%^**$%@#$!That", "thisthat")]
@ -290,7 +287,6 @@ namespace NzbDrone.Core.Test
result.Should().Be(clean);
}
[TestCase("the")]
[TestCase("and")]
[TestCase("or")]
@ -360,7 +356,6 @@ namespace NzbDrone.Core.Test
result.Should().Be(Parser.NormalizeTitle(title));
}
[TestCase("Castle.2009.S01E14.English.HDTV.XviD-LOL", LanguageType.English)]
[TestCase("Castle.2009.S01E14.French.HDTV.XviD-LOL", LanguageType.French)]
[TestCase("Castle.2009.S01E14.Spanish.HDTV.XviD-LOL", LanguageType.Spanish)]
@ -445,5 +440,16 @@ namespace NzbDrone.Core.Test
ExceptionVerification.IgnoreWarns();
ExceptionVerification.ExpectedErrors(1);
}
[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)
{
Parser.ParseReleaseGroup(title).Should().Be(expected);
}
}
}

@ -0,0 +1,69 @@
// ReSharper disable RedundantUsingDirective
using System.Linq;
using System;
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.DecisionEngine;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class AllowedReleaseGroupSpecificationFixture : CoreTest
{
private EpisodeParseResult parseResult;
[SetUp]
public void Setup()
{
parseResult = new EpisodeParseResult
{
SeriesTitle = "Title",
Language = LanguageType.English,
Quality = new Quality(QualityTypes.SDTV, true),
EpisodeNumbers = new List<int> { 3 },
SeasonNumber = 12,
AirDate = DateTime.Now.AddDays(-12).Date,
ReleaseGroup = "2HD"
};
}
[Test]
public void should_be_true_when_allowedReleaseGroups_is_empty()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.AllowedReleaseGroups).Returns(String.Empty);
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
}
[Test]
public void should_be_true_when_allowedReleaseGroups_is_nzbs_releaseGroup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD");
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
}
[Test]
public void should_be_true_when_allowedReleaseGroups_contains_nzbs_releaseGroup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD, LOL");
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
}
[Test]
public void should_be_false_when_allowedReleaseGroups_does_not_contain_nzbs_releaseGroup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.AllowedReleaseGroups).Returns("LOL,DTD");
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeFalse();
}
}
}

@ -201,7 +201,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Returns(fakeEpisode);
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries.Title, It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries.Title, It.IsAny<QualityTypes>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Returns(filename);
Mocker.GetMock<MediaFileProvider>()
@ -298,7 +298,7 @@ namespace NzbDrone.Core.Test.ProviderTests
Mocker.GetMock<EpisodeProvider>().Setup(s => s.GetEpisodesByFileId(episodeFile.EpisodeFileId))
.Returns(episode);
Mocker.GetMock<MediaFileProvider>().Setup(s => s.GetNewFilename(It.IsAny<IList<Episode>>(), series.Title, QualityTypes.Unknown, false))
Mocker.GetMock<MediaFileProvider>().Setup(s => s.GetNewFilename(It.IsAny<IList<Episode>>(), series.Title, QualityTypes.Unknown, false, It.IsAny<EpisodeFile>()))
.Returns(newFilename);
Mocker.GetMock<MediaFileProvider>().Setup(s => s.CalculateFilePath(It.IsAny<Series>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()))
@ -350,7 +350,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Returns(fakeEpisode);
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries.Title, It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries.Title, It.IsAny<QualityTypes>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Returns(filename);
Mocker.GetMock<MediaFileProvider>()

@ -1,7 +1,7 @@
// ReSharper disable RedundantUsingDirective
using System.Collections.Generic;
using System.IO;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
@ -39,7 +39,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("South Park - S15E06 - City Sushi [HDTV]", result);
@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("15x06 - City Sushi [HDTV]", result);
@ -93,7 +93,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("South Park 05x06 [HDTV]", result);
@ -121,7 +121,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("South Park s05e06", result);
@ -148,7 +148,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("South.Park.s05e06.City.Sushi", result);
@ -175,7 +175,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("South.Park.-.s05e06.-.City.Sushi.[HDTV]", result);
@ -203,7 +203,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("S15E06", result);
@ -237,7 +237,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("The Mentalist - S03E23-E24 - Strawberries and Cream (1) + Strawberries and Cream (2) [HDTV]", result);
@ -271,7 +271,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("3x23x24 - Strawberries and Cream (1) + Strawberries and Cream (2) [HDTV]", result);
@ -305,7 +305,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("3x23x24 Strawberries and Cream (1) + Strawberries and Cream (2) [HDTV]", result);
@ -339,7 +339,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("The.Mentalist.s03e23.s03e24.Strawberries.and.Cream.(1).+.Strawberries.and.Cream.(2)", result);
@ -373,7 +373,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("The.Mentalist.-.S03E23-24", result);
@ -407,7 +407,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("3x23x24", result);
@ -432,7 +432,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, true);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, true, new EpisodeFile());
//Assert
result.Should().Be("South Park - S15E06 - City Sushi [HDTV] [Proper]");
@ -457,7 +457,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
result.Should().Be("South Park - S15E06 - City Sushi [HDTV]");
@ -482,7 +482,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, true);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, true, new EpisodeFile());
//Assert
result.Should().Be("South Park - S15E06 - City Sushi");
@ -514,7 +514,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, "30 Rock", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, "30 Rock", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong! (1) + Hey, Baby, What's Wrong! (2)");
@ -541,7 +541,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("South Park.S15E06.City Sushi [HDTV]", result);
@ -568,10 +568,72 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("15x06.City Sushi [HDTV]", result);
}
[Test]
public void GetNewFilename_UseSceneName_when_sceneName_isNull()
{
//Setup
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(2);
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
fakeConfig.SetupGet(c => c.SortingUseSceneName).Returns(true);
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
.With(e => e.SeasonNumber = 15)
.With(e => e.EpisodeNumber = 6)
.Build();
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(e => e.SceneName = null)
.With(e => e.Path = @"C:\Test\TV\30 Rock - S01E01 - Test")
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, episodeFile);
//Assert
result.Should().Be(Path.GetFileNameWithoutExtension(episodeFile.Path));
}
[Test]
public void GetNewFilename_UseSceneName_when_sceneName_isNotNull()
{
//Setup
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(2);
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
fakeConfig.SetupGet(c => c.SortingUseSceneName).Returns(true);
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
.With(e => e.SeasonNumber = 15)
.With(e => e.EpisodeNumber = 6)
.Build();
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(e => e.SceneName = "30.Rock.S01E01.xvid-LOL")
.With(e => e.Path = @"C:\Test\TV\30 Rock - S01E01 - Test")
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, episodeFile);
//Assert
result.Should().Be(episodeFile.SceneName);
}
}
}

@ -49,11 +49,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("Title1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("Title2");
//Act
@ -98,11 +98,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("New Title 1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("New Title 2");
//Act
@ -147,11 +147,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("New Title 1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("Title2");
//Act
@ -198,11 +198,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("New Title 1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("Title2");
//Act
@ -249,11 +249,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("Title1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("Title2");
//Act

@ -0,0 +1,19 @@
using System;
using System.Data;
using Migrator.Framework;
using NzbDrone.Common;
namespace NzbDrone.Core.Datastore.Migrations
{
[Migration(20120802)]
public class Migration20120802 : NzbDroneMigration
{
protected override void MainDbUpgrade()
{
Database.AddColumn("EpisodeFiles", new Column("SceneName", DbType.String, ColumnProperty.Null));
Database.AddColumn("EpisodeFiles", new Column("ReleaseGroup", DbType.String, ColumnProperty.Null));
Database.AddColumn("History", new Column("ReleaseGroup", DbType.String, ColumnProperty.Null));
}
}
}

@ -44,6 +44,8 @@ namespace NzbDrone.Core.Model
public int Age { get; set; }
public string ReleaseGroup { get; set; }
public override string ToString()
{

@ -16,6 +16,7 @@ namespace NzbDrone.Core.Model
public bool IsProper { get; set; }
public string Indexer { get; set; }
public string NzbInfoUrl { get; set; }
public string ReleaseGroup { get; set; }
public string EpisodeTitle { get; set; }
public int SeasonNumber { get; set; }

@ -17,5 +17,6 @@ namespace NzbDrone.Core.Model
DownloadClientFailure = 10,
Skipped = 11,
Failure = 12,
ReleaseGroupNotWanted = 13
}
}

@ -227,6 +227,7 @@
<Compile Include="Datastore\MigrationLogger.cs" />
<Compile Include="Datastore\MigrationsHelper.cs" />
<Compile Include="Datastore\CustomeMapper.cs" />
<Compile Include="Datastore\Migrations\Migration20120802.cs" />
<Compile Include="Datastore\Migrations\Migration20120727.cs" />
<Compile Include="Datastore\Migrations\Migration20120504.cs" />
<Compile Include="Datastore\Migrations\Migration20120430.cs" />
@ -287,6 +288,7 @@
<Compile Include="Model\Xbmc\ErrorResult.cs" />
<Compile Include="Model\Xbmc\IconType.cs" />
<Compile Include="Providers\BannerProvider.cs" />
<Compile Include="Providers\DecisionEngine\AllowedReleaseGroupSpecification.cs" />
<Compile Include="Providers\Indexer\NzbClub.cs" />
<Compile Include="Providers\Indexer\NzbIndex.cs" />
<Compile Include="Providers\Indexer\FileSharingTalk.cs" />

File diff suppressed because one or more lines are too long

@ -214,6 +214,12 @@ namespace NzbDrone.Core.Providers.Core
set { SetValue("Sorting_MultiEpisodeStyle", value); }
}
public virtual bool SortingUseSceneName
{
get { return GetValueBoolean("Sorting_UseSceneName", false); }
set { SetValue("Sorting_UseSceneName", value); }
}
public virtual int DefaultQualityProfile
{
get { return GetValueInt("DefaultQualityProfile", 1); }
@ -508,6 +514,12 @@ namespace NzbDrone.Core.Providers.Core
set { SetValue("MetadataUseBanners", value); }
}
public virtual string AllowedReleaseGroups
{
get { return GetValue("AllowedReleaseGroups"); }
set { SetValue("AllowedReleaseGroups", value); }
}
private string GetValue(string key)
{
return GetValue(key, String.Empty);

@ -13,18 +13,21 @@ namespace NzbDrone.Core.Providers.DecisionEngine
private readonly AcceptableSizeSpecification _acceptableSizeSpecification;
private readonly AlreadyInQueueSpecification _alreadyInQueueSpecification;
private readonly RetentionSpecification _retentionSpecification;
private readonly AllowedReleaseGroupSpecification _allowedReleaseGroupSpecification;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
[Inject]
public AllowedDownloadSpecification(QualityAllowedByProfileSpecification qualityAllowedByProfileSpecification,
UpgradeDiskSpecification upgradeDiskSpecification, AcceptableSizeSpecification acceptableSizeSpecification,
AlreadyInQueueSpecification alreadyInQueueSpecification, RetentionSpecification retentionSpecification)
AlreadyInQueueSpecification alreadyInQueueSpecification, RetentionSpecification retentionSpecification,
AllowedReleaseGroupSpecification allowedReleaseGroupSpecification)
{
_qualityAllowedByProfileSpecification = qualityAllowedByProfileSpecification;
_upgradeDiskSpecification = upgradeDiskSpecification;
_acceptableSizeSpecification = acceptableSizeSpecification;
_alreadyInQueueSpecification = alreadyInQueueSpecification;
_retentionSpecification = retentionSpecification;
_allowedReleaseGroupSpecification = allowedReleaseGroupSpecification;
}
public AllowedDownloadSpecification()
@ -37,8 +40,9 @@ namespace NzbDrone.Core.Providers.DecisionEngine
if (!_upgradeDiskSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.ExistingQualityIsEqualOrBetter;
if (!_retentionSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.Retention;
if (!_acceptableSizeSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.Size;
if (!_allowedReleaseGroupSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.ReleaseGroupNotWanted;
if (_alreadyInQueueSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.AlreadyInQueue;
logger.Debug("Episode {0} is needed", subject);
return ReportRejectionType.None;
}

@ -0,0 +1,48 @@
using System;
using System.Linq;
using NLog;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers.DecisionEngine
{
public class AllowedReleaseGroupSpecification
{
private readonly ConfigProvider _configProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
[Inject]
public AllowedReleaseGroupSpecification(ConfigProvider configProvider)
{
_configProvider = configProvider;
}
public AllowedReleaseGroupSpecification()
{
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
{
logger.Trace("Beginning release group check for: {0}", subject);
var allowed = _configProvider.AllowedReleaseGroups;
if (string.IsNullOrWhiteSpace(allowed))
return true;
foreach(var group in allowed.Trim(',', ' ').Split(','))
{
if (subject.ReleaseGroup.Equals(group.Trim(' '), StringComparison.CurrentCultureIgnoreCase))
{
logger.Trace("Item: {0}'s release group is wanted: {1}", subject, subject.ReleaseGroup);
return true;
}
}
logger.Trace("Item: {0}'s release group is not wanted: {1}", subject, subject.ReleaseGroup);
return false;
}
}
}

@ -153,6 +153,8 @@ namespace NzbDrone.Core.Providers
episodeFile.Quality = parseResult.Quality.QualityType;
episodeFile.Proper = parseResult.Quality.Proper;
episodeFile.SeasonNumber = parseResult.SeasonNumber;
episodeFile.SceneName = Path.GetFileNameWithoutExtension(filePath.NormalizePath());
episodeFile.ReleaseGroup = parseResult.ReleaseGroup;
var fileId = _mediaFileProvider.Add(episodeFile);
//Link file to all episodes
@ -175,7 +177,7 @@ namespace NzbDrone.Core.Providers
var series = _seriesProvider.GetSeries(episodeFile.SeriesId);
var episodes = _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId);
string newFileName = _mediaFileProvider.GetNewFilename(episodes, series.Title, episodeFile.Quality, episodeFile.Proper);
string newFileName = _mediaFileProvider.GetNewFilename(episodes, series.Title, episodeFile.Quality, episodeFile.Proper, episodeFile);
var newFile = _mediaFileProvider.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
//Only rename if existing and new filenames don't match

@ -63,6 +63,7 @@ namespace NzbDrone.Core.Providers
history.EpisodeId = episode.EpisodeId;
history.SeriesId = episode.SeriesId;
history.NzbInfoUrl = parseResult.NzbInfoUrl;
history.ReleaseGroup = parseResult.ReleaseGroup;
_historyProvider.Add(history);
_episodeProvider.MarkEpisodeAsFetched(episode.EpisodeId);

@ -63,7 +63,6 @@ namespace NzbDrone.Core.Providers.Indexer
get { return null; }
}
protected abstract IList<String> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber);
protected abstract IList<String> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date);
protected abstract IList<String> GetSeasonSearchUrls(string seriesTitle, int seasonNumber);

@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using Ninject;
using NzbDrone.Common;
using NzbDrone.Core.Model;
@ -44,7 +46,6 @@ namespace NzbDrone.Core.Providers.Indexer
}
}
protected override NetworkCredential Credentials
{
get { return new NetworkCredential(_configProvider.NewzbinUsername, _configProvider.NewzbinPassword); }
@ -90,7 +91,6 @@ namespace NzbDrone.Core.Providers.Indexer
};
}
public override string Name
{
get { return "Newzbin"; }
@ -118,10 +118,25 @@ namespace NzbDrone.Core.Providers.Indexer
var sizeString = Regex.Match(item.Summary.Text, @"\(Size: \d*\,?\d+\.\d{1,2}\w{2}\)", RegexOptions.IgnoreCase).Value;
currentResult.Size = Parser.GetReportSize(sizeString);
try
{
var releaseGroupText = item.ElementExtensions.Single(s => s.OuterName == "nfo")
.GetObject<XElement>()
.Element(XName.Get("filename", "http://www.newzbin2.es/DTD/2007/feeds/report/"))
.Value;
var releaseGroup = Parser.ParseReleaseGroup(releaseGroupText.Replace(".nfo", ""));
currentResult.ReleaseGroup = releaseGroup;
}
catch(Exception ex)
{
_logger.TraceException("Error getting release group for newzbin release", ex);
currentResult.ReleaseGroup = "";
}
}
return currentResult;
}
}
}

@ -142,8 +142,22 @@ namespace NzbDrone.Core.Providers
}
}
public virtual string GetNewFilename(IList<Episode> episodes, string seriesTitle, QualityTypes quality, bool proper)
public virtual string GetNewFilename(IList<Episode> episodes, string seriesTitle, QualityTypes quality, bool proper, EpisodeFile episodeFile)
{
if (_configProvider.SortingUseSceneName)
{
Logger.Trace("Attempting to use scene name");
if (String.IsNullOrWhiteSpace(episodeFile.SceneName))
{
var name = Path.GetFileNameWithoutExtension(episodeFile.Path);
Logger.Trace("Unable to use scene name, because it is null, sticking with current name: {0}", name);
return name;
}
return episodeFile.SceneName;
}
var sortedEpisodes = episodes.OrderBy(e => e.EpisodeNumber);
var separatorStyle = EpisodeSortingHelper.GetSeparatorStyle(_configProvider.SortingSeparatorStyle);

@ -29,7 +29,6 @@ namespace NzbDrone.Core.Providers
var episodesWithFiles = _episodeProvider.EpisodesWithFiles().GroupBy(e => e.EpisodeFileId).ToList();
totalItems = episodesWithFiles.Count();
var stopwatch = new Stopwatch();
stopwatch.Start();
@ -37,7 +36,7 @@ namespace NzbDrone.Core.Providers
w =>
w.First().EpisodeFile.Path !=
_mediaFileProvider.GetNewFilename(w.Select(e => e).ToList(), w.First().Series.Title,
w.First().EpisodeFile.Quality, w.First().EpisodeFile.Proper)).Skip(Math.Max(pageSize * (pageNumber - 1), 0)).Take(pageSize);
w.First().EpisodeFile.Quality, w.First().EpisodeFile.Proper, w.First().EpisodeFile)).Skip(Math.Max(pageSize * (pageNumber - 1), 0)).Take(pageSize);
//Process the episodes
misnamedFilesSelect.AsParallel().ForAll(f =>
@ -46,7 +45,7 @@ namespace NzbDrone.Core.Providers
var firstEpisode = episodes[0];
var properName = _mediaFileProvider.GetNewFilename(episodes,
firstEpisode.Series.Title,
firstEpisode.EpisodeFile.Quality, firstEpisode.EpisodeFile.Proper);
firstEpisode.EpisodeFile.Quality, firstEpisode.EpisodeFile.Proper, firstEpisode.EpisodeFile);
var currentName = Path.GetFileNameWithoutExtension(firstEpisode.EpisodeFile.Path);

@ -34,6 +34,8 @@ namespace NzbDrone.Core.Repository
public bool Proper { get; set; }
public long Size { get; set; }
public DateTime DateAdded { get; set; }
public string SceneName { get; set; }
public string ReleaseGroup { get; set; }
[Ignore]
public Model.Quality QualityWrapper

@ -17,6 +17,7 @@ namespace NzbDrone.Core.Repository
public bool IsProper { get; set; }
public string Indexer { get; set; }
public string NzbInfoUrl { get; set; }
public string ReleaseGroup { get; set; }
[ResultColumn]
public Episode Episode { get; set; }

@ -48,7 +48,8 @@ namespace NzbDrone.Web.Controllers
DateSorter = h.Date.ToString("MM/dd/yyyy h:mm:ss tt"),
Indexer = h.Indexer,
EpisodeId = h.EpisodeId,
NzbInfoUrl = h.NzbInfoUrl
NzbInfoUrl = h.NzbInfoUrl,
ReleaseGroup = h.ReleaseGroup
});
return Json(new

@ -205,6 +205,7 @@ namespace NzbDrone.Web.Controllers
model.SeparatorStyle = _configProvider.SortingSeparatorStyle;
model.NumberStyle = _configProvider.SortingNumberStyle;
model.MultiEpisodeStyle = _configProvider.SortingMultiEpisodeStyle;
model.SceneName = _configProvider.SortingUseSceneName;
model.SeparatorStyles = new SelectList(EpisodeSortingHelper.GetSeparatorStyles(), "Id", "Name");
model.NumberStyles = new SelectList(EpisodeSortingHelper.GetNumberStyles(), "Id", "Name");
@ -243,6 +244,7 @@ namespace NzbDrone.Web.Controllers
var model = new MiscSettingsModel();
model.EnableBacklogSearching = _configProvider.EnableBacklogSearching;
model.AutoIgnorePreviouslyDownloadedEpisodes = _configProvider.AutoIgnorePreviouslyDownloadedEpisodes;
model.AllowedReleaseGroups = _configProvider.AllowedReleaseGroups;
return View(model);
}
@ -594,6 +596,7 @@ namespace NzbDrone.Web.Controllers
_configProvider.SortingSeparatorStyle = data.SeparatorStyle;
_configProvider.SortingNumberStyle = data.NumberStyle;
_configProvider.SortingMultiEpisodeStyle = data.MultiEpisodeStyle;
_configProvider.SortingUseSceneName = data.SceneName;
//Metadata
_configProvider.MetadataUseBanners = data.MetadataUseBanners;
@ -631,6 +634,7 @@ namespace NzbDrone.Web.Controllers
{
_configProvider.EnableBacklogSearching = data.EnableBacklogSearching;
_configProvider.AutoIgnorePreviouslyDownloadedEpisodes = data.AutoIgnorePreviouslyDownloadedEpisodes;
_configProvider.AllowedReleaseGroups = data.AllowedReleaseGroups;
return GetSuccessResult();
}

@ -43,6 +43,10 @@ namespace NzbDrone.Web.Models
[Description("How will multi-episode files be named?")]
public int MultiEpisodeStyle { get; set; }
[DisplayName("Use Scene Name")]
[Description("Use the scene name, ignoring all other naming settings?")]
public bool SceneName { get; set; }
[DisplayName("XBMC")]
[Description("Enable creating metadata for XBMC")]
public bool MetadataXbmcEnabled { get; set; }

@ -21,5 +21,6 @@ namespace NzbDrone.Web.Models
public int EpisodeId { get; set; }
public string Details { get; set; }
public string NzbInfoUrl { get; set; }
public string ReleaseGroup { get; set; }
}
}

@ -15,5 +15,9 @@ namespace NzbDrone.Web.Models
[DisplayName("Automatically Ignore Deleted Episodes")]
[Description("Should NzbDrone automatically ignore episodes that were deleted from disk?")]
public bool AutoIgnorePreviouslyDownloadedEpisodes { get; set; }
[DisplayName("Allowed Release Groups")]
[Description("Comma separated list of release groups to download episodes")]
public string AllowedReleaseGroups { get; set; }
}
}

@ -112,6 +112,9 @@
"<b>Proper: </b>" + row.aData["IsProper"] + "<br/>" +
"<b>Indexer: </b>" + row.aData["Indexer"].replace('_', ' - ');
if (row.aData["ReleaseGroup"] != null && row.aData["ReleaseGroup"] != "")
result += "<br/><b>Release Group: </b> " + row.aData["ReleaseGroup"];
if (row.aData["NzbInfoUrl"] != null && row.aData["NzbInfoUrl"] != "")
result += "<br/><b>Nzb Details: </b> <a href=\"" + row.aData["NzbInfoUrl"] + "\" target=\"_blank\">Details</a>";

@ -6,6 +6,10 @@
<div class="settingsContainer">
@Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.")
<label class="labelClass">@Html.LabelFor(m => m.SceneName)
<span class="small">@Html.DescriptionFor(m => m.SceneName)</span>
</label>
@Html.CheckBoxFor(m => m.SceneName, new { @class = "inputClass checkClass" })
<label class="labelClass">@Html.LabelFor(m => m.SeriesName)
<span class="small">@Html.DescriptionFor(m => m.SeriesName)</span>
</label>

@ -19,6 +19,11 @@
</label>
@Html.CheckBoxFor(m => m.AutoIgnorePreviouslyDownloadedEpisodes, new { @class = "inputClass checkClass" })
<label class="labelClass">@Html.LabelFor(m => m.AllowedReleaseGroups)
<span class="small">@Html.DescriptionFor(m => m.AllowedReleaseGroups)</span>
</label>
@Html.TextBoxFor(m => m.AllowedReleaseGroups, new { @class = "inputClass" })
<div style="overflow: hidden; height: 50px;">
</div>

Loading…
Cancel
Save