mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Merge branch 'xem' into 'master'
Conflicts: NzbDrone.Common/DiskProvider.cs NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs NzbDrone.Core/Providers/DecisionEngine/CustomStartDateSpecification.cs NzbDrone.Core/Providers/DiskScanProvider.cs NzbDrone.Core/Providers/DownloadProvider.cs
This commit is contained in:
commit
5bbe310af5
Binary file not shown.
Binary file not shown.
@ -175,6 +175,18 @@ public void check_last_write()
|
||||
Console.WriteLine(new DirectoryInfo(@"C:\DRIVERS").LastWriteTimeUtc);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsChildOfPath_should_return_true_when_it_is_a_child()
|
||||
{
|
||||
Mocker.Resolve<DiskProvider>().IsChildOfPath(@"C:\Test\TV", @"C:\Test").Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsChildOfPath_should_return_false_when_it_is_not_a_child()
|
||||
{
|
||||
Mocker.Resolve<DiskProvider>().IsChildOfPath(@"C:\NOT_Test\TV", @"C:\Test").Should().BeFalse();
|
||||
}
|
||||
|
||||
private void VerifyCopy()
|
||||
{
|
||||
BinFolder.Refresh();
|
||||
|
@ -268,5 +268,12 @@ public virtual bool IsFileLocked(FileInfo file)
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool IsChildOfPath(string child, string parent)
|
||||
{
|
||||
if (Path.GetFullPath(child).StartsWith(Path.GetFullPath(parent)))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
7
NzbDrone.Core.Test/Files/Xem/Failure.txt
Normal file
7
NzbDrone.Core.Test/Files/Xem/Failure.txt
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
|
||||
"result": "failure",
|
||||
"data": [ ],
|
||||
"message": "no show with the tvdb_id 79488 found"
|
||||
|
||||
}
|
10
NzbDrone.Core.Test/Files/Xem/Ids.txt
Normal file
10
NzbDrone.Core.Test/Files/Xem/Ids.txt
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
|
||||
"result": "success",
|
||||
"data": [
|
||||
"73141",
|
||||
"79886",
|
||||
],
|
||||
"message": ""
|
||||
|
||||
}
|
32
NzbDrone.Core.Test/Files/Xem/Mappings.txt
Normal file
32
NzbDrone.Core.Test/Files/Xem/Mappings.txt
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
|
||||
"result": "success",
|
||||
"data": [
|
||||
{
|
||||
"scene": {
|
||||
"season": 1,
|
||||
"episode": 1,
|
||||
"absolute": 1
|
||||
},
|
||||
"tvdb": {
|
||||
"season": 1,
|
||||
"episode": 1,
|
||||
"absolute": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"scene": {
|
||||
"season": 1,
|
||||
"episode": 2,
|
||||
"absolute": 2
|
||||
},
|
||||
"tvdb": {
|
||||
"season": 1,
|
||||
"episode": 2,
|
||||
"absolute": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"message": "full mapping for 73388 on tvdb. this was a cached version"
|
||||
|
||||
}
|
24
NzbDrone.Core.Test/Files/Xem/Names.txt
Normal file
24
NzbDrone.Core.Test/Files/Xem/Names.txt
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
|
||||
"result": "success",
|
||||
"data": {
|
||||
"220571": [
|
||||
"Is This a Zombie? Of the Dead",
|
||||
"Kore wa Zombie Desuka?",
|
||||
"Kore wa Zombie Desuka? Of the Dead",
|
||||
"Kore wa Zombie Desuka Of the Dead",
|
||||
"Kore wa Zombie Desu ka - Of the Dead",
|
||||
"Kore wa Zombie Desu ka of the Dead"
|
||||
],
|
||||
"79151": [
|
||||
"Fate Stay Night",
|
||||
"Fate/Zero",
|
||||
"Fate Zero",
|
||||
"Fate/Zero (2012)",
|
||||
"Fate Zero S2",
|
||||
"Fate Zero"
|
||||
]
|
||||
},
|
||||
"message": ""
|
||||
|
||||
}
|
@ -42,13 +42,15 @@ public void import_new_series_succesful()
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)))
|
||||
.Callback(() => series[0].LastDiskSync = DateTime.Now);
|
||||
|
||||
|
||||
Mocker.GetMock<DiskScanJob>()
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[1].SeriesId)))
|
||||
.Callback(() => series[1].LastDiskSync = DateTime.Now);
|
||||
|
||||
Mocker.GetMock<BannerDownloadJob>()
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0)));
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") > 0)));
|
||||
|
||||
Mocker.GetMock<XemUpdateJob>()
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") > 0)));
|
||||
|
||||
Mocker.GetMock<UpdateInfoJob>()
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)))
|
||||
@ -121,6 +123,9 @@ public void failed_import_should_not_be_stuck_in_loop()
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
.Setup(s => s.GetSeriesFiles(It.IsAny<int>())).Returns(new List<EpisodeFile>());
|
||||
|
||||
Mocker.GetMock<XemUpdateJob>()
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, null);
|
||||
|
||||
|
@ -129,13 +129,14 @@
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="TvdbLib, Version=0.8.8.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\TvdbLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WebActivator, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\WebActivator.1.5\lib\net40\WebActivator.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="XemLib">
|
||||
<HintPath>..\Libraries\XemLib\XemLib.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="QualityTypesTest.cs" />
|
||||
@ -156,6 +157,7 @@
|
||||
<Compile Include="ProviderTests\DiskScanProviderTests\GetVideoFilesFixture.cs" />
|
||||
<Compile Include="ProviderTests\DiskScanProviderTests\ScanFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\PneumaticProviderFixture.cs" />
|
||||
<Compile Include="ProviderTests\EpisodeProviderTests\GetEpisodeBySceneNumberFixture.cs" />
|
||||
<Compile Include="ProviderTests\Metadata\Xbmc_ForEpisodeFile_Fixture.cs" />
|
||||
<Compile Include="ProviderTests\Metadata\Xbmc_ForSeries_Fixture.cs" />
|
||||
<Compile Include="ProviderTests\PostDownloadProviderTests\ProcessDropDirectoryFixture.cs" />
|
||||
@ -194,9 +196,11 @@
|
||||
<Compile Include="JobTests\AppUpdateJobFixture.cs" />
|
||||
<Compile Include="ProviderTests\UpdateProviderTests\GetUpdateLogFixture.cs" />
|
||||
<Compile Include="ProviderTests\UpdateProviderTests\GetAvilableUpdateFixture.cs" />
|
||||
<Compile Include="ProviderTests\XemCommunicationProviderTests\GetSceneTvdbMappingsFixture.cs" />
|
||||
<Compile Include="ProviderTests\XemCommunicationProviderTests\GetXemSeriesIdsFixture.cs" />
|
||||
<Compile Include="Services\ParseErrorServiceFixture.cs" />
|
||||
<Compile Include="SortHelperTest.cs" />
|
||||
<Compile Include="ProviderTests\EpisodeProviderTest_DeleteInvalidEpisodes.cs" />
|
||||
<Compile Include="ProviderTests\EpisodeProviderTests\EpisodeProviderTest_DeleteInvalidEpisodes.cs" />
|
||||
<Compile Include="ProviderTests\DecisionEngineTests\AcceptableSizeSpecificationFixture.cs" />
|
||||
<Compile Include="ProviderTests\QualityTypeProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\MisnamedProviderTest.cs" />
|
||||
@ -206,7 +210,7 @@
|
||||
<Compile Include="CentralDispatchFixture.cs" />
|
||||
<Compile Include="ProviderTests\XbmcProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\DiskScanProviderTests\MoveEpisodeFileFixture.cs" />
|
||||
<Compile Include="ProviderTests\EpisodeProviderTest_GetEpisodesByParseResult.cs" />
|
||||
<Compile Include="ProviderTests\EpisodeProviderTests\EpisodeProviderTest_GetEpisodesByParseResult.cs" />
|
||||
<Compile Include="ProviderTests\DiskScanProviderTests\ImportFileFixture.cs" />
|
||||
<Compile Include="FluentTest.cs" />
|
||||
<Compile Include="ProviderTests\LogProviderTests\LogProviderFixture.cs" />
|
||||
@ -228,7 +232,7 @@
|
||||
<Compile Include="ProviderTests\HistoryProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\MediaFileProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\ConfigProviderTests\ConfigProviderFixture.cs" />
|
||||
<Compile Include="ProviderTests\EpisodeProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\EpisodeProviderTests\EpisodeProviderTest.cs" />
|
||||
<Compile Include="Framework\TestDbHelper.cs" />
|
||||
<Compile Include="ParserFixture\ParserTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@ -335,6 +339,18 @@
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Content Include="Files\Xem\Ids.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Xem\Failure.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Xem\Names.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Files\Xem\Mappings.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="log.config">
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
|
@ -32,6 +32,9 @@ public void Setup()
|
||||
{
|
||||
_customStartDateSpecification = Mocker.Resolve<CustomStartDateSpecification>();
|
||||
|
||||
firstEpisode = new Episode { AirDate = DateTime.Today };
|
||||
secondEpisode = new Episode { AirDate = DateTime.Today };
|
||||
|
||||
fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.Monitored = true)
|
||||
.With(c => c.CustomStartDate = null)
|
||||
@ -43,6 +46,7 @@ public void Setup()
|
||||
Series = fakeSeries,
|
||||
EpisodeNumbers = new List<int> { 3, 4 },
|
||||
SeasonNumber = 12,
|
||||
Episodes = new List<Episode> { firstEpisode, secondEpisode }
|
||||
};
|
||||
|
||||
parseResultSingle = new EpisodeParseResult
|
||||
@ -51,16 +55,8 @@ public void Setup()
|
||||
Series = fakeSeries,
|
||||
EpisodeNumbers = new List<int> { 3 },
|
||||
SeasonNumber = 12,
|
||||
Episodes = new List<Episode> { firstEpisode }
|
||||
};
|
||||
|
||||
firstEpisode = new Episode { AirDate = DateTime.Today };
|
||||
secondEpisode = new Episode { AirDate = DateTime.Today };
|
||||
|
||||
var singleEpisodeList = new List<Episode> { firstEpisode };
|
||||
var doubleEpisodeList = new List<Episode> { firstEpisode, secondEpisode };
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(c => c.GetEpisodesByParseResult(parseResultSingle)).Returns(singleEpisodeList);
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(c => c.GetEpisodesByParseResult(parseResultMulti)).Returns(doubleEpisodeList);
|
||||
}
|
||||
|
||||
private void WithFirstEpisodeLastYear()
|
||||
|
@ -31,6 +31,12 @@ public void Setup()
|
||||
Mocker.Resolve<QualityUpgradeSpecification>();
|
||||
_upgradeDisk = Mocker.Resolve<UpgradeDiskSpecification>();
|
||||
|
||||
firstFile = new EpisodeFile { Quality = QualityTypes.Bluray1080p, Proper = true };
|
||||
secondFile = new EpisodeFile { Quality = QualityTypes.Bluray1080p, Proper = true };
|
||||
|
||||
var singleEpisodeList = new List<Episode> { new Episode { EpisodeFile = firstFile }, new Episode { EpisodeFile = null } };
|
||||
var doubleEpisodeList = new List<Episode> { new Episode { EpisodeFile = firstFile }, new Episode { EpisodeFile = secondFile }, new Episode { EpisodeFile = null } };
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile { Cutoff = QualityTypes.Bluray1080p })
|
||||
.Build();
|
||||
@ -41,6 +47,7 @@ public void Setup()
|
||||
Quality = new QualityModel(QualityTypes.DVD, true),
|
||||
EpisodeNumbers = new List<int> { 3, 4 },
|
||||
SeasonNumber = 12,
|
||||
Episodes = doubleEpisodeList
|
||||
};
|
||||
|
||||
parseResultSingle = new EpisodeParseResult
|
||||
@ -49,17 +56,8 @@ public void Setup()
|
||||
Quality = new QualityModel(QualityTypes.DVD, true),
|
||||
EpisodeNumbers = new List<int> { 3 },
|
||||
SeasonNumber = 12,
|
||||
Episodes = singleEpisodeList
|
||||
};
|
||||
|
||||
|
||||
firstFile = new EpisodeFile { Quality = QualityTypes.Bluray1080p, Proper = true };
|
||||
secondFile = new EpisodeFile { Quality = QualityTypes.Bluray1080p, Proper = true };
|
||||
|
||||
var singleEpisodeList = new List<Episode> { new Episode { EpisodeFile = firstFile }, new Episode { EpisodeFile = null } };
|
||||
var doubleEpisodeList = new List<Episode> { new Episode { EpisodeFile = firstFile }, new Episode { EpisodeFile = secondFile }, new Episode { EpisodeFile = null } };
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(c => c.GetEpisodesByParseResult(parseResultSingle)).Returns(singleEpisodeList);
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(c => c.GetEpisodesByParseResult(parseResultMulti)).Returns(doubleEpisodeList);
|
||||
}
|
||||
|
||||
private void WithFirstFileUpgradable()
|
||||
@ -73,9 +71,9 @@ private void WithSecondFileUpgradable()
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_single_episode_doesnt_exist_on_disk()
|
||||
public void should_return_true_if_single_episode_doesnt_exist_on_disk()
|
||||
{
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(c => c.GetEpisodesByParseResult(parseResultSingle)).Returns(new List<Episode>());
|
||||
parseResultSingle.Episodes = new List<Episode>();
|
||||
|
||||
_upgradeDisk.IsSatisfiedBy(parseResultSingle).Should().BeTrue();
|
||||
}
|
||||
|
@ -31,6 +31,13 @@ public void Setup()
|
||||
Mocker.Resolve<QualityUpgradeSpecification>();
|
||||
_upgradeHistory = Mocker.Resolve<UpgradeHistorySpecification>();
|
||||
|
||||
var singleEpisodeList = new List<Episode> { new Episode { SeasonNumber = 12, EpisodeNumber = 3 } };
|
||||
var doubleEpisodeList = new List<Episode> {
|
||||
new Episode { SeasonNumber = 12, EpisodeNumber = 3 },
|
||||
new Episode { SeasonNumber = 12, EpisodeNumber = 4 },
|
||||
new Episode { SeasonNumber = 12, EpisodeNumber = 5 }
|
||||
};
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile { Cutoff = QualityTypes.Bluray1080p })
|
||||
.Build();
|
||||
@ -41,6 +48,7 @@ public void Setup()
|
||||
Quality = new QualityModel(QualityTypes.DVD, true),
|
||||
EpisodeNumbers = new List<int> { 3, 4 },
|
||||
SeasonNumber = 12,
|
||||
Episodes = doubleEpisodeList
|
||||
};
|
||||
|
||||
parseResultSingle = new EpisodeParseResult
|
||||
@ -49,21 +57,12 @@ public void Setup()
|
||||
Quality = new QualityModel(QualityTypes.DVD, true),
|
||||
EpisodeNumbers = new List<int> { 3 },
|
||||
SeasonNumber = 12,
|
||||
Episodes = singleEpisodeList
|
||||
};
|
||||
|
||||
firstQuality = new QualityModel(QualityTypes.Bluray1080p, true);
|
||||
secondQuality = new QualityModel(QualityTypes.Bluray1080p, true);
|
||||
|
||||
var singleEpisodeList = new List<Episode> { new Episode { SeasonNumber = 12, EpisodeNumber = 3 } };
|
||||
var doubleEpisodeList = new List<Episode> {
|
||||
new Episode { SeasonNumber = 12, EpisodeNumber = 3 },
|
||||
new Episode { SeasonNumber = 12, EpisodeNumber = 4 },
|
||||
new Episode { SeasonNumber = 12, EpisodeNumber = 5 }
|
||||
};
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(c => c.GetEpisodesByParseResult(parseResultSingle)).Returns(singleEpisodeList);
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(c => c.GetEpisodesByParseResult(parseResultMulti)).Returns(doubleEpisodeList);
|
||||
|
||||
Mocker.GetMock<HistoryProvider>().Setup(c => c.GetBestQualityInHistory(fakeSeries.SeriesId, 12, 3)).Returns(firstQuality);
|
||||
Mocker.GetMock<HistoryProvider>().Setup(c => c.GetBestQualityInHistory(fakeSeries.SeriesId, 12, 4)).Returns(secondQuality);
|
||||
Mocker.GetMock<HistoryProvider>().Setup(c => c.GetBestQualityInHistory(fakeSeries.SeriesId, 12, 5)).Returns<QualityModel>(null);
|
||||
|
@ -175,6 +175,9 @@ public void import_file_with_no_episode_in_db_should_skip()
|
||||
.Setup(p => p.Exists(It.IsAny<String>()))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<DiskProvider>(MockBehavior.Strict)
|
||||
.Setup(e => e.IsChildOfPath(fileName, fakeSeries.Path)).Returns(false);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
|
||||
.Returns(new List<Episode>());
|
||||
@ -392,5 +395,47 @@ private static void VerifySkipImport(EpisodeFile result, AutoMoqer Mocker)
|
||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.UpdateEpisode(It.IsAny<Episode>()), Times.Never());
|
||||
Mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_set_parseResult_SceneSource_if_not_in_series_Path()
|
||||
{
|
||||
var series = Builder<Series>
|
||||
.CreateNew()
|
||||
.With(s => s.Path == @"C:\Test\TV\30 Rock")
|
||||
.Build();
|
||||
|
||||
const string path = @"C:\Test\Unsorted TV\30 Rock\30.rock.s01e01.pilot.mkv";
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(s => s.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
|
||||
.Returns(new List<Episode>());
|
||||
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.IsChildOfPath(path, series.Path))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.Resolve<DiskScanProvider>().ImportFile(series, path);
|
||||
|
||||
Mocker.Verify<EpisodeProvider>(s => s.GetEpisodesByParseResult(It.Is<EpisodeParseResult>(p => p.SceneSource)), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_set_parseResult_SceneSource_if_in_series_Path()
|
||||
{
|
||||
var series = Builder<Series>
|
||||
.CreateNew()
|
||||
.With(s => s.Path == @"C:\Test\TV\30 Rock")
|
||||
.Build();
|
||||
|
||||
const string path = @"C:\Test\TV\30 Rock\30.rock.s01e01.pilot.mkv";
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(s => s.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
|
||||
.Returns(new List<Episode>());
|
||||
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.IsChildOfPath(path, series.Path))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.Resolve<DiskScanProvider>().ImportFile(series, path);
|
||||
|
||||
Mocker.Verify<EpisodeProvider>(s => s.GetEpisodesByParseResult(It.Is<EpisodeParseResult>(p => p.SceneSource == false)), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ private EpisodeParseResult SetupParseResult()
|
||||
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, false))
|
||||
.With(c => c.Series = Builder<Series>.CreateNew().Build())
|
||||
.With(c => c.EpisodeNumbers = new List<int>{2})
|
||||
.With(c => c.Episodes = episodes)
|
||||
.Build();
|
||||
}
|
||||
|
||||
@ -191,6 +192,15 @@ public void create_proper_sab_titles(int seasons, int[] episodes, string title,
|
||||
.With(c => c.Title = "My Series Name")
|
||||
.Build();
|
||||
|
||||
var fakeEpisodes = new List<Episode>();
|
||||
|
||||
foreach(var episode in episodes)
|
||||
fakeEpisodes.Add(Builder<Episode>
|
||||
.CreateNew()
|
||||
.With(e => e.EpisodeNumber = episode)
|
||||
.With(e => e.Title = title)
|
||||
.Build());
|
||||
|
||||
var parsResult = new EpisodeParseResult()
|
||||
{
|
||||
AirDate = DateTime.Now,
|
||||
@ -198,7 +208,8 @@ public void create_proper_sab_titles(int seasons, int[] episodes, string title,
|
||||
Quality = new QualityModel(quality, proper),
|
||||
SeasonNumber = seasons,
|
||||
Series = series,
|
||||
EpisodeTitle = title
|
||||
EpisodeTitle = title,
|
||||
Episodes = fakeEpisodes
|
||||
};
|
||||
|
||||
Mocker.Resolve<DownloadProvider>().GetDownloadTitle(parsResult).Should().Be(expected);
|
||||
@ -234,16 +245,49 @@ public string create_proper_sab_daily_titles(bool proper)
|
||||
.With(c => c.Title = "My Series Name")
|
||||
.Build();
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "My Episode Title")
|
||||
.Build();
|
||||
|
||||
var parsResult = new EpisodeParseResult
|
||||
{
|
||||
AirDate = new DateTime(2011, 12, 1),
|
||||
Quality = new QualityModel(QualityTypes.Bluray720p, proper),
|
||||
Series = series,
|
||||
EpisodeTitle = "My Episode Title",
|
||||
Episodes = new List<Episode>{ episode }
|
||||
};
|
||||
|
||||
return Mocker.Resolve<DownloadProvider>().GetDownloadTitle(parsResult);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_repeat_the_same_episode_title()
|
||||
{
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(c => c.Title = "My Series Name")
|
||||
.Build();
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.SeasonNumber = 5)
|
||||
.TheFirst(1)
|
||||
.With(e => e.Title = "My Episode Title (1)")
|
||||
.TheLast(1)
|
||||
.With(e => e.Title = "My Episode Title (2)")
|
||||
.Build();
|
||||
|
||||
var parsResult = new EpisodeParseResult
|
||||
{
|
||||
AirDate = DateTime.Now,
|
||||
EpisodeNumbers = new List<int>{ 10, 11 },
|
||||
Quality = new QualityModel(QualityTypes.HDTV, false),
|
||||
SeasonNumber = 35,
|
||||
Series = series,
|
||||
Episodes = fakeEpisodes
|
||||
};
|
||||
|
||||
Mocker.Resolve<DownloadProvider>().GetDownloadTitle(parsResult).Should().Be("My Series Name - 5x01-5x02 - My Episode Title [HDTV]");
|
||||
}
|
||||
}
|
||||
}
|
@ -2,9 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@ -15,11 +13,10 @@
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
using XemLib.Data;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
@ -161,7 +158,7 @@ public void RefreshEpisodeInfo_emptyRepo()
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = "en")
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build())
|
||||
).With(c => c.Id = seriesId).Build();
|
||||
|
||||
@ -172,7 +169,7 @@ public void RefreshEpisodeInfo_emptyRepo()
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
Mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
@ -195,7 +192,7 @@ public void RefreshEpisodeInfo_should_set_older_than_1900_to_null()
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(10).
|
||||
All()
|
||||
.With(l => l.Language = "en").And(e => e.FirstAired = DateTime.Now)
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a")).And(e => e.FirstAired = DateTime.Now)
|
||||
.TheFirst(7).With(e => e.FirstAired = new DateTime(1800, 1, 1))
|
||||
.Build())
|
||||
).With(c => c.Id = seriesId).Build();
|
||||
@ -207,7 +204,7 @@ public void RefreshEpisodeInfo_should_set_older_than_1900_to_null()
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
Mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(fakeEpisodes);
|
||||
|
||||
|
||||
@ -236,7 +233,7 @@ public void RefreshEpisodeInfo_should_set_older_than_1900_to_null_for_existing_e
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(l => l.Language = "en").And(e => e.FirstAired = DateTime.Now)
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a")).And(e => e.FirstAired = DateTime.Now)
|
||||
.TheFirst(1).With(e => e.FirstAired = new DateTime(1800, 1, 1))
|
||||
.Build())
|
||||
).With(c => c.Id = seriesId).Build();
|
||||
@ -248,7 +245,7 @@ public void RefreshEpisodeInfo_should_set_older_than_1900_to_null_for_existing_e
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
Mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(fakeTvDbEpisodes);
|
||||
|
||||
//Act
|
||||
@ -271,7 +268,7 @@ public void RefreshEpisodeInfo_ignore_episode_zero()
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = "en")
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.TheFirst(1)
|
||||
.With(e => e.EpisodeNumber = 0)
|
||||
.With(e => e.SeasonNumber = 15)
|
||||
@ -285,7 +282,7 @@ public void RefreshEpisodeInfo_ignore_episode_zero()
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
Mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(fakeEpisodes);
|
||||
|
||||
|
||||
@ -324,7 +321,7 @@ public void RefreshEpisodeInfo_should_skip_future_episodes_with_no_title()
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
Mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(fakeEpisodes);
|
||||
|
||||
|
||||
@ -362,7 +359,7 @@ public void RefreshEpisodeInfo_should_skip_older_than_1900_year_episodes_with_no
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
Mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(fakeEpisodes);
|
||||
|
||||
|
||||
@ -395,7 +392,7 @@ public void RefreshEpisodeInfo_should_add_future_episodes_with_title()
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
Mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(fakeEpisodes);
|
||||
|
||||
|
||||
@ -428,7 +425,7 @@ public void RefreshEpisodeInfo_should_add_old_episodes_with_no_title()
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
Mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(fakeEpisodes);
|
||||
|
||||
|
||||
@ -451,7 +448,7 @@ public void RefreshEpisodeInfo_ignore_season_zero()
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = "en")
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.With(e => e.SeasonNumber = 0)
|
||||
.Build())
|
||||
).With(c => c.Id = seriesId).Build();
|
||||
@ -463,7 +460,7 @@ public void RefreshEpisodeInfo_ignore_season_zero()
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
Mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(fakeEpisodes);
|
||||
|
||||
Mocker.GetMock<SeasonProvider>()
|
||||
@ -493,7 +490,7 @@ public void new_episodes_only_calls_Insert()
|
||||
var currentEpisodes = new List<Episode>();
|
||||
|
||||
Mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(tvdbSeries);
|
||||
|
||||
Mocker.GetMock<IDatabase>()
|
||||
@ -528,7 +525,7 @@ public void existing_episodes_only_calls_Update()
|
||||
}
|
||||
|
||||
Mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(tvdbSeries);
|
||||
|
||||
Mocker.GetMock<IDatabase>()
|
||||
@ -565,7 +562,7 @@ public void should_try_to_get_existing_episode_using_tvdbid_first()
|
||||
.Returns(fakeEpisodeList);
|
||||
|
||||
Mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(fakeTvDbResult);
|
||||
|
||||
//Act
|
||||
@ -602,7 +599,7 @@ public void should_try_to_get_existing_episode_using_tvdbid_first_then_season_ep
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
||||
|
||||
Mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(tvdbSeries);
|
||||
|
||||
Mocker.GetMock<IDatabase>()
|
||||
@ -643,7 +640,7 @@ public void existing_episodes_keep_their_episodeId_file_id()
|
||||
}
|
||||
|
||||
Mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(tvdbSeries);
|
||||
|
||||
var updatedEpisodes = new List<Episode>();
|
||||
@ -692,7 +689,7 @@ public void existing_episodes_remote_their_episodeId_file_id_when_episode_number
|
||||
}
|
||||
|
||||
Mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(tvdbSeries);
|
||||
|
||||
var updatedEpisodes = new List<Episode>();
|
||||
@ -738,7 +735,7 @@ public void existing_episodes_remote_their_episodeId_file_id_when_season_number_
|
||||
}
|
||||
|
||||
Mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(tvdbSeries);
|
||||
|
||||
var updatedEpisodes = new List<Episode>();
|
||||
@ -777,7 +774,7 @@ public void RefreshEpisodeInfo_should_ignore_new_episode_for_ignored_season()
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = "en")
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.With(e => e.SeasonNumber = 5)
|
||||
.TheFirst(1)
|
||||
.With(e => e.EpisodeNumber = 1)
|
||||
@ -796,7 +793,7 @@ public void RefreshEpisodeInfo_should_ignore_new_episode_for_ignored_season()
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
Mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(tvdbSeries);
|
||||
|
||||
Mocker.GetMock<SeasonProvider>()
|
||||
@ -1487,7 +1484,7 @@ public void RefreshEpisodeInfo_should_ignore_episode_zero_except_if_season_one()
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = "en")
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.With(e => e.EpisodeNumber = 0)
|
||||
.TheFirst(1)
|
||||
.With(e => e.SeasonNumber = 1)
|
||||
@ -1509,7 +1506,7 @@ public void RefreshEpisodeInfo_should_ignore_episode_zero_except_if_season_one()
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
Mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false, false))
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(tvdbSeries);
|
||||
|
||||
//Act
|
@ -2,17 +2,15 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using XemLib.Data;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
@ -27,7 +25,7 @@ public void Delete_None_Valid_TvDbEpisodeId()
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = "en")
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
|
||||
@ -65,7 +63,7 @@ public void Delete_None_TvDbEpisodeId_is_zero()
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = "en")
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
@ -102,7 +100,7 @@ public void Delete_None_TvDbEpisodeId_is_null()
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = "en")
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
@ -139,7 +137,7 @@ public void Delete_TvDbId()
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = "en")
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
@ -179,7 +177,7 @@ public void Delete_TvDbId_multiple_series()
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = "en")
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
@ -5,17 +5,14 @@
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
@ -0,0 +1,77 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class GetEpisodeBySceneNumberFixture : CoreTest
|
||||
{
|
||||
private Series _series;
|
||||
private Episode _episode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
_series = Builder<Series>
|
||||
.CreateNew()
|
||||
.Build();
|
||||
|
||||
Db.Insert(_series);
|
||||
}
|
||||
|
||||
public void WithNullSceneNumbering()
|
||||
{
|
||||
_episode = Builder<Episode>
|
||||
.CreateNew()
|
||||
.With(e => e.SeriesId = _series.SeriesId)
|
||||
.Build();
|
||||
|
||||
Db.Insert(_episode);
|
||||
Db.Execute("UPDATE Episodes SET SceneSeasonNumber = NULL, SceneEpisodeNumber = NULL");
|
||||
}
|
||||
|
||||
public void WithSceneNumbering()
|
||||
{
|
||||
_episode = Builder<Episode>
|
||||
.CreateNew()
|
||||
.With(e => e.SeriesId = _series.SeriesId)
|
||||
.Build();
|
||||
|
||||
Db.Insert(_episode);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_null_if_no_episodes_in_db()
|
||||
{
|
||||
Mocker.Resolve<EpisodeProvider>().GetEpisodeBySceneNumbering(_series.SeriesId, 1, 1).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_null_if_no_matching_episode_is_found()
|
||||
{
|
||||
WithNullSceneNumbering();
|
||||
Mocker.Resolve<EpisodeProvider>().GetEpisodeBySceneNumbering(_series.SeriesId, 1, 1).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_episode_if_matching_episode_is_found()
|
||||
{
|
||||
WithSceneNumbering();
|
||||
|
||||
var result = Mocker.Resolve<EpisodeProvider>()
|
||||
.GetEpisodeBySceneNumbering(_series.SeriesId, _episode.SceneSeasonNumber, _episode.SceneEpisodeNumber);
|
||||
|
||||
result.EpisodeId.Should().Be(_episode.EpisodeId);
|
||||
}
|
||||
}
|
||||
}
|
@ -699,5 +699,43 @@ public void should_have_two_episodeTitles_when_episode_titles_are_not_the_same()
|
||||
//Assert
|
||||
result.Should().Be("30 Rock - S06E06-E07 - Hello + World");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_have_two_episodeTitles_when_distinct_count_is_two()
|
||||
{
|
||||
//Setup
|
||||
var fakeConfig = Mocker.GetMock<ConfigProvider>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "Hello (3)")
|
||||
.With(e => e.SeasonNumber = 6)
|
||||
.With(e => e.EpisodeNumber = 6)
|
||||
.Build();
|
||||
|
||||
var episode2 = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "Hello (2)")
|
||||
.With(e => e.SeasonNumber = 6)
|
||||
.With(e => e.EpisodeNumber = 7)
|
||||
.Build();
|
||||
|
||||
var episode3 = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "World")
|
||||
.With(e => e.SeasonNumber = 6)
|
||||
.With(e => e.EpisodeNumber = 8)
|
||||
.Build();
|
||||
|
||||
//Act
|
||||
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode, episode2, episode3 }, "30 Rock", QualityTypes.HDTV, false, new EpisodeFile());
|
||||
|
||||
//Assert
|
||||
result.Should().Be("30 Rock - S06E06-E07-E08 - Hello + World");
|
||||
}
|
||||
}
|
||||
}
|
@ -17,8 +17,8 @@
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using NzbDrone.Test.Common;
|
||||
using XemLib.Data;
|
||||
using XemLib.Data.Banner;
|
||||
using TvdbLib.Data;
|
||||
using TvdbLib.Data.Banner;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.Metadata
|
||||
{
|
||||
@ -52,30 +52,31 @@ public void Setup()
|
||||
.With(e => e.SeriesId = 79488)
|
||||
.With(e => e.SeasonNumber = 1)
|
||||
.With(e => e.Directors = new List<string>{ "Fake Director" })
|
||||
.With(e => e.Writers = new List<string>{ "Fake Writer" })
|
||||
.With(e => e.Writer = new List<string>{ "Fake Writer" })
|
||||
.With(e => e.GuestStars = new List<string> { "Guest Star 1", "Guest Star 2", "Guest Star 3", "" })
|
||||
.Build();
|
||||
|
||||
var seasonBanners = Builder<TvdbSeasonBanner>
|
||||
.CreateListOfSize(4)
|
||||
.TheFirst(2)
|
||||
.With(b => b.SeasonNumber = 1)
|
||||
.With(b => b.Season = 1)
|
||||
.TheLast(2)
|
||||
.With(b => b.SeasonNumber = 2)
|
||||
.With(b => b.Season = 2)
|
||||
.TheFirst(1)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.Poster)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.season)
|
||||
.With(b => b.BannerPath = "seasons/79488-1-1.jpg")
|
||||
.TheNext(2)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.Banner)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.seasonwide)
|
||||
.With(b => b.BannerPath = "banners/seasons/79488-test.jpg")
|
||||
.TheLast(1)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.Poster)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.season)
|
||||
.With(b => b.BannerPath = "seasons/79488-2-1.jpg")
|
||||
.Build();
|
||||
|
||||
var seriesActors = Builder<TvdbActor>
|
||||
.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(a => a.ActorImage = Builder<TvdbActorBanner>.CreateNew().Build())
|
||||
.Build();
|
||||
|
||||
tvdbSeries = Builder<TvdbSeries>
|
||||
@ -84,10 +85,9 @@ public void Setup()
|
||||
.With(s => s.SeriesName = "30 Rock")
|
||||
.With(s => s.TvdbActors = seriesActors.ToList())
|
||||
.With(s => s.Episodes = tvdbEpisodes.ToList())
|
||||
.With(s => s.Banners = new TvdbBanners())
|
||||
.Build();
|
||||
|
||||
tvdbSeries.Banners.SeasonBanners.AddRange(seasonBanners);
|
||||
tvdbSeries.Banners.AddRange(seasonBanners);
|
||||
}
|
||||
|
||||
private void WithUseBanners()
|
||||
@ -128,7 +128,7 @@ private void WithNoDirectors()
|
||||
|
||||
private void WithNoWriters()
|
||||
{
|
||||
tvdbSeries.Episodes.ForEach(e => e.Writers = new List<string>());
|
||||
tvdbSeries.Episodes.ForEach(e => e.Writer = new List<string>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -159,7 +159,7 @@ public void should_download_thumbnail_when_thumbnail_path_is_not_null()
|
||||
{
|
||||
WithSingleEpisodeFile();
|
||||
Mocker.Resolve<Xbmc>().CreateForEpisodeFile(episodeFile, tvdbSeries);
|
||||
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.Episodes.First().Banner, episodeFile.Path.Replace("avi", "tbn")), Times.Once());
|
||||
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.Episodes.First().BannerPath, episodeFile.Path.Replace("avi", "tbn")), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@ -17,8 +16,8 @@
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using NzbDrone.Test.Common;
|
||||
using XemLib.Data;
|
||||
using XemLib.Data.Banner;
|
||||
using TvdbLib.Data;
|
||||
using TvdbLib.Data.Banner;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.Metadata
|
||||
{
|
||||
@ -43,23 +42,24 @@ public void Setup()
|
||||
var seasonBanners = Builder<TvdbSeasonBanner>
|
||||
.CreateListOfSize(4)
|
||||
.TheFirst(2)
|
||||
.With(b => b.SeasonNumber = 1)
|
||||
.With(b => b.Season = 1)
|
||||
.TheLast(2)
|
||||
.With(b => b.SeasonNumber = 2)
|
||||
.With(b => b.Season = 2)
|
||||
.TheFirst(1)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.Poster)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.season)
|
||||
.With(b => b.BannerPath = "seasons/79488-1-1.jpg")
|
||||
.TheNext(2)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.Banner)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.seasonwide)
|
||||
.With(b => b.BannerPath = "banners/seasons/79488-test.jpg")
|
||||
.TheLast(1)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.Poster)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.season)
|
||||
.With(b => b.BannerPath = "seasons/79488-2-1.jpg")
|
||||
.Build();
|
||||
|
||||
var seriesActors = Builder<TvdbActor>
|
||||
.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(a => a.ActorImage = Builder<TvdbActorBanner>.CreateNew().Build())
|
||||
.Build();
|
||||
|
||||
tvdbSeries = Builder<TvdbSeries>
|
||||
@ -67,10 +67,9 @@ public void Setup()
|
||||
.With(s => s.Id = 79488)
|
||||
.With(s => s.SeriesName = "30 Rock")
|
||||
.With(s => s.TvdbActors = seriesActors.ToList())
|
||||
.With(s => s.Banners = new TvdbBanners())
|
||||
.Build();
|
||||
|
||||
tvdbSeries.Banners.SeasonBanners.AddRange(seasonBanners);
|
||||
tvdbSeries.Banners.AddRange(seasonBanners);
|
||||
}
|
||||
|
||||
private void WithUseBanners()
|
||||
@ -83,18 +82,19 @@ private void WithSpecials()
|
||||
var seasonBanners = Builder<TvdbSeasonBanner>
|
||||
.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(b => b.SeasonNumber = 0)
|
||||
.With(b => b.Season = 0)
|
||||
.TheFirst(1)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.Poster)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.season)
|
||||
.With(b => b.BannerPath = "seasons/79488-0-1.jpg")
|
||||
.TheLast(1)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.Banner)
|
||||
.With(b => b.BannerType = TvdbSeasonBanner.Type.seasonwide)
|
||||
.With(b => b.BannerPath = "banners/seasons/79488-0-1.jpg")
|
||||
.Build();
|
||||
|
||||
var seriesActors = Builder<TvdbActor>
|
||||
.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(a => a.ActorImage = Builder<TvdbActorBanner>.CreateNew().Build())
|
||||
.Build();
|
||||
|
||||
tvdbSeries = Builder<TvdbSeries>
|
||||
@ -102,11 +102,9 @@ private void WithSpecials()
|
||||
.With(s => s.Id = 79488)
|
||||
.With(s => s.SeriesName = "30 Rock")
|
||||
.With(s => s.TvdbActors = seriesActors.ToList())
|
||||
.With(s => s.Banners = new TvdbBanners())
|
||||
.With(s => s.Genres = new List<String> { "Comedy" })
|
||||
.Build();
|
||||
|
||||
tvdbSeries.Banners.SeasonBanners.AddRange(seasonBanners);
|
||||
tvdbSeries.Banners.AddRange(seasonBanners);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -126,14 +124,14 @@ public void should_call_diskprovider_writeAllText()
|
||||
public void should_download_fanart()
|
||||
{
|
||||
Mocker.Resolve<Xbmc>().CreateForSeries(series, tvdbSeries);
|
||||
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.Fanart, Path.Combine(series.Path, "fanart.jpg")), Times.Once());
|
||||
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.FanartPath, Path.Combine(series.Path, "fanart.jpg")), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_download_poster_when_useBanners_is_false()
|
||||
{
|
||||
Mocker.Resolve<Xbmc>().CreateForSeries(series, tvdbSeries);
|
||||
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.Poster, Path.Combine(series.Path, "folder.jpg")), Times.Once());
|
||||
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.PosterPath, Path.Combine(series.Path, "folder.jpg")), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -141,7 +139,7 @@ public void should_download_banner_when_useBanners_is_true()
|
||||
{
|
||||
WithUseBanners();
|
||||
Mocker.Resolve<Xbmc>().CreateForSeries(series, tvdbSeries);
|
||||
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.Banner, Path.Combine(series.Path, "folder.jpg")), Times.Once());
|
||||
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(tvdbSeries.BannerPath, Path.Combine(series.Path, "folder.jpg")), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -18,6 +18,7 @@
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
||||
{
|
||||
|
@ -185,7 +185,7 @@ public void PartialSeasonSearch_should_skip_daily_series()
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EpisodeSearch_should_skip_if_air_date_is_null()
|
||||
public void EpisodeSearch_should_skip_if_air_date_is_null_and_is_a_daily_series()
|
||||
{
|
||||
//Setup
|
||||
_series.IsDaily = true;
|
||||
|
@ -16,6 +16,7 @@
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
|
@ -10,8 +10,8 @@
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using XemLib.Data;
|
||||
using XemLib.Exceptions;
|
||||
using TvdbLib.Data;
|
||||
using TvdbLib.Exceptions;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
@ -30,7 +30,7 @@ public void Setup()
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
ExceptionVerification.MarkInconclusive(typeof(TheTvbdbUnavailableException));
|
||||
ExceptionVerification.MarkInconclusive(typeof(TvdbNotAvailableException));
|
||||
}
|
||||
|
||||
[TestCase("The Simpsons")]
|
||||
|
@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.XemCommunicationProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class GetSceneTvdbMappingsFixture : CoreTest
|
||||
{
|
||||
private void WithFailureJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Xem\Failure.txt"));
|
||||
}
|
||||
|
||||
private void WithIdsJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Xem\Ids.txt"));
|
||||
}
|
||||
|
||||
private void WithMappingsJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Xem\Mappings.txt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_when_failure_is_found()
|
||||
{
|
||||
WithFailureJson();
|
||||
Assert.Throws<Exception>(() => Mocker.Resolve<XemCommunicationProvider>().GetSceneTvdbMappings(12345));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_list_of_mappings()
|
||||
{
|
||||
WithMappingsJson();
|
||||
Mocker.Resolve<XemCommunicationProvider>().GetSceneTvdbMappings(12345).Should().NotBeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_have_two_mappings()
|
||||
{
|
||||
WithMappingsJson();
|
||||
Mocker.Resolve<XemCommunicationProvider>().GetSceneTvdbMappings(12345).Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_have_expected_results()
|
||||
{
|
||||
WithMappingsJson();
|
||||
var results = Mocker.Resolve<XemCommunicationProvider>().GetSceneTvdbMappings(12345);
|
||||
var first = results.First();
|
||||
first.Scene.Absolute.Should().Be(1);
|
||||
first.Scene.Season.Should().Be(1);
|
||||
first.Scene.Episode.Should().Be(1);
|
||||
first.Tvdb.Absolute.Should().Be(1);
|
||||
first.Tvdb.Season.Should().Be(1);
|
||||
first.Tvdb.Episode.Should().Be(1);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.XemCommunicationProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class GetXemSeriesIdsFixture : CoreTest
|
||||
{
|
||||
private void WithFailureJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Xem\Failure.txt"));
|
||||
}
|
||||
|
||||
private void WithIdsJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Xem\Ids.txt"));
|
||||
}
|
||||
|
||||
private void WithMappingsJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Xem\Mappings.txt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_when_failure_is_found()
|
||||
{
|
||||
WithFailureJson();
|
||||
Assert.Throws<Exception>(() => Mocker.Resolve<XemCommunicationProvider>().GetXemSeriesIds());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_list_of_int()
|
||||
{
|
||||
WithIdsJson();
|
||||
Mocker.Resolve<XemCommunicationProvider>().GetXemSeriesIds().Should().NotBeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_have_two_ids()
|
||||
{
|
||||
WithIdsJson();
|
||||
Mocker.Resolve<XemCommunicationProvider>().GetXemSeriesIds().Should().HaveCount(2);
|
||||
}
|
||||
}
|
||||
}
|
@ -137,6 +137,7 @@ private void InitJobs()
|
||||
Kernel.Bind<IJob>().To<RefreshEpisodeMetadata>().InSingletonScope();
|
||||
Kernel.Bind<IJob>().To<CleanupRecycleBinJob>().InSingletonScope();
|
||||
Kernel.Bind<IJob>().To<EmptyRecycleBinJob>().InSingletonScope();
|
||||
Kernel.Bind<IJob>().To<XemUpdateJob>().InSingletonScope();
|
||||
|
||||
Kernel.Get<JobProvider>().Initialize();
|
||||
Kernel.Get<WebTimer>().StartTimer(30);
|
||||
|
20
NzbDrone.Core/Datastore/Migrations/Migration20121016.cs
Normal file
20
NzbDrone.Core/Datastore/Migrations/Migration20121016.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20121016)]
|
||||
public class Migration20121016 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("Episodes", new Column("SceneAbsoluteEpisodeNumber", DbType.Int32, ColumnProperty.Null));
|
||||
Database.AddColumn("Episodes", new Column("SceneSeasonNumber", DbType.Int32, ColumnProperty.Null));
|
||||
Database.AddColumn("Episodes", new Column("SceneEpisodeNumber", DbType.Int32, ColumnProperty.Null));
|
||||
|
||||
Database.AddColumn("Series", new Column("UseSceneNumbering", DbType.Boolean, ColumnProperty.Null));
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ public class ImportNewSeriesJob : IJob
|
||||
private readonly DiskScanJob _diskScanJob;
|
||||
private readonly BannerDownloadJob _bannerDownloadJob;
|
||||
private readonly SeasonProvider _seasonProvider;
|
||||
private readonly XemUpdateJob _xemUpdateJob;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
@ -30,7 +31,8 @@ public class ImportNewSeriesJob : IJob
|
||||
[Inject]
|
||||
public ImportNewSeriesJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
|
||||
MediaFileProvider mediaFileProvider, UpdateInfoJob updateInfoJob,
|
||||
DiskScanJob diskScanJob, BannerDownloadJob bannerDownloadJob,SeasonProvider seasonProvider)
|
||||
DiskScanJob diskScanJob, BannerDownloadJob bannerDownloadJob,
|
||||
SeasonProvider seasonProvider, XemUpdateJob xemUpdateJob)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
@ -39,6 +41,7 @@ public ImportNewSeriesJob(SeriesProvider seriesProvider, EpisodeProvider episode
|
||||
_diskScanJob = diskScanJob;
|
||||
_bannerDownloadJob = bannerDownloadJob;
|
||||
_seasonProvider = seasonProvider;
|
||||
_xemUpdateJob = xemUpdateJob;
|
||||
}
|
||||
|
||||
public string Name
|
||||
@ -81,6 +84,9 @@ private void ScanSeries(ProgressNotification notification)
|
||||
//Download the banner for the new series
|
||||
_bannerDownloadJob.Start(notification, new { SeriesId = updatedSeries.SeriesId });
|
||||
|
||||
//Get Scene Numbering if applicable
|
||||
_xemUpdateJob.Start(notification, new { SeriesId = updatedSeries.SeriesId });
|
||||
|
||||
notification.CurrentMessage = String.Format("{0} was successfully imported", updatedSeries.Title);
|
||||
}
|
||||
|
||||
|
57
NzbDrone.Core/Jobs/XemUpdateJob.cs
Normal file
57
NzbDrone.Core/Jobs/XemUpdateJob.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using Ninject;
|
||||
using NzbDrone.Core.Helpers;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
public class XemUpdateJob : IJob
|
||||
{
|
||||
private readonly XemProvider _xemProvider;
|
||||
|
||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[Inject]
|
||||
public XemUpdateJob(XemProvider xemProvider)
|
||||
{
|
||||
_xemProvider = xemProvider;
|
||||
}
|
||||
|
||||
public XemUpdateJob()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "XEM Update"; }
|
||||
}
|
||||
|
||||
public TimeSpan DefaultInterval
|
||||
{
|
||||
get { return TimeSpan.FromHours(12); }
|
||||
}
|
||||
|
||||
public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
{
|
||||
if (options == null || options.SeriesId == 0)
|
||||
{
|
||||
_logger.Trace("Starting XEM Update for all series");
|
||||
_xemProvider.UpdateMappings();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
_logger.Trace("Starting XEM Update for series: {0}", options.SeriesId);
|
||||
_xemProvider.UpdateMappings(options.SeriesId);
|
||||
}
|
||||
|
||||
_logger.Trace("XEM Update complete");
|
||||
}
|
||||
}
|
||||
}
|
@ -46,6 +46,10 @@ public string CleanTitle
|
||||
|
||||
public string ReleaseGroup { get; set; }
|
||||
|
||||
public bool SceneSource { get; set; }
|
||||
|
||||
public IList<Episode> Episodes { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
|
14
NzbDrone.Core/Model/Xem/XemResult.cs
Normal file
14
NzbDrone.Core/Model/Xem/XemResult.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Model.Xem
|
||||
{
|
||||
public class XemResult<T>
|
||||
{
|
||||
public string Result { get; set; }
|
||||
public T Data { get; set; }
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
13
NzbDrone.Core/Model/Xem/XemSceneTvdbMapping.cs
Normal file
13
NzbDrone.Core/Model/Xem/XemSceneTvdbMapping.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Model.Xem
|
||||
{
|
||||
public class XemSceneTvdbMapping
|
||||
{
|
||||
public XemValues Scene { get; set; }
|
||||
public XemValues Tvdb { get; set; }
|
||||
}
|
||||
}
|
14
NzbDrone.Core/Model/Xem/XemValues.cs
Normal file
14
NzbDrone.Core/Model/Xem/XemValues.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Model.Xem
|
||||
{
|
||||
public class XemValues
|
||||
{
|
||||
public int Season { get; set; }
|
||||
public int Episode { get; set; }
|
||||
public int Absolute { get; set; }
|
||||
}
|
||||
}
|
@ -206,6 +206,10 @@
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.XML" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="TvdbLib, Version=0.8.8.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\TvdbLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Twitterizer2, Version=2.4.0.26532, Culture=neutral, PublicKeyToken=69d1469eac671567, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\twitterizer.2.4.0.26532\lib\net40\Twitterizer2.dll</HintPath>
|
||||
</Reference>
|
||||
@ -213,9 +217,6 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\WebActivator.1.5\lib\net40\WebActivator.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="XemLib">
|
||||
<HintPath>..\Libraries\XemLib\XemLib.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\NzbDrone.Common\Properties\SharedAssemblyInfo.cs">
|
||||
@ -226,6 +227,7 @@
|
||||
<Compile Include="Datastore\MigrationLogger.cs" />
|
||||
<Compile Include="Datastore\MigrationsHelper.cs" />
|
||||
<Compile Include="Datastore\CustomeMapper.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20121016.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20121012.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120919.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120918.cs" />
|
||||
@ -256,6 +258,7 @@
|
||||
<Compile Include="Helpers\SortHelper.cs" />
|
||||
<Compile Include="Helpers\SabnzbdPriorityTypeConverter.cs" />
|
||||
<Compile Include="Jobs\CleanupRecycleBinJob.cs" />
|
||||
<Compile Include="Jobs\XemUpdateJob.cs" />
|
||||
<Compile Include="Jobs\EmptyRecycleBinJob.cs" />
|
||||
<Compile Include="Jobs\RefreshEpsiodeMetadata.cs" />
|
||||
<Compile Include="Jobs\PastWeekBacklogSearchJob.cs" />
|
||||
@ -291,6 +294,9 @@
|
||||
<Compile Include="Model\Xbmc\TvShowResult.cs" />
|
||||
<Compile Include="Model\Xbmc\ErrorResult.cs" />
|
||||
<Compile Include="Model\Xbmc\IconType.cs" />
|
||||
<Compile Include="Model\Xem\XemResult.cs" />
|
||||
<Compile Include="Model\Xem\XemSceneTvdbMapping.cs" />
|
||||
<Compile Include="Model\Xem\XemValues.cs" />
|
||||
<Compile Include="Providers\BannerProvider.cs" />
|
||||
<Compile Include="Providers\DecisionEngine\AllowedReleaseGroupSpecification.cs" />
|
||||
<Compile Include="Providers\DecisionEngine\CustomStartDateSpecification.cs" />
|
||||
@ -329,6 +335,8 @@
|
||||
<Compile Include="Jobs\RssSyncJob.cs" />
|
||||
<Compile Include="Jobs\UpdateInfoJob.cs" />
|
||||
<Compile Include="Providers\StatsProvider.cs" />
|
||||
<Compile Include="Providers\XemCommunicationProvider.cs" />
|
||||
<Compile Include="Providers\XemProvider.cs" />
|
||||
<Compile Include="Repository\MetadataDefinition.cs" />
|
||||
<Compile Include="Repository\Quality\QualityTypes.cs" />
|
||||
<Compile Include="Repository\Search\SearchHistoryItem.cs" />
|
||||
|
@ -42,6 +42,7 @@ public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||
}
|
||||
|
||||
var episodes = _episodeProvider.GetEpisodesByParseResult(subject);
|
||||
subject.Episodes = episodes;
|
||||
|
||||
//return monitored if any of the episodes are monitored
|
||||
if (episodes.Any(episode => !episode.Ignored))
|
||||
|
@ -24,7 +24,7 @@ public UpgradeDiskSpecification()
|
||||
|
||||
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||
{
|
||||
foreach (var file in _episodeProvider.GetEpisodesByParseResult(subject).Select(c => c.EpisodeFile).Where(c => c != null))
|
||||
foreach (var file in subject.Episodes.Select(c => c.EpisodeFile).Where(c => c != null))
|
||||
{
|
||||
logger.Trace("Comparing file quality with report. Existing file is {0} proper:{1}", file.Quality, file.Proper);
|
||||
if (!_qualityUpgradeSpecification.IsSatisfiedBy(new QualityModel { Quality = file.Quality, Proper = file.Proper }, subject.Quality, subject.Series.QualityProfile.Cutoff))
|
||||
|
@ -27,7 +27,7 @@ public UpgradeHistorySpecification()
|
||||
|
||||
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||
{
|
||||
foreach (var episode in _episodeProvider.GetEpisodesByParseResult(subject))
|
||||
foreach (var episode in subject.Episodes)
|
||||
{
|
||||
var bestQualityInHistory = _historyProvider.GetBestQualityInHistory(subject.Series.SeriesId, episode.SeasonNumber, episode.EpisodeNumber);
|
||||
if (bestQualityInHistory != null)
|
||||
|
@ -122,6 +122,9 @@ public virtual EpisodeFile ImportFile(Series series, string filePath)
|
||||
if (parseResult == null)
|
||||
return null;
|
||||
|
||||
if (!_diskProvider.IsChildOfPath(filePath, series.Path))
|
||||
parseResult.SceneSource = true;
|
||||
|
||||
parseResult.SeriesTitle = series.Title; //replaces the nasty path as title to help with logging
|
||||
parseResult.Series = series;
|
||||
|
||||
@ -203,6 +206,7 @@ public virtual EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, bool newDown
|
||||
var parseResult = Parser.ParsePath(episodeFile.Path);
|
||||
parseResult.Series = series;
|
||||
parseResult.Quality = new QualityModel{ Quality = episodeFile.Quality, Proper = episodeFile.Proper };
|
||||
parseResult.Episodes = episodes;
|
||||
|
||||
var message = _downloadProvider.GetDownloadTitle(parseResult);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Model;
|
||||
@ -48,13 +49,13 @@ public virtual bool DownloadReport(EpisodeParseResult parseResult)
|
||||
|
||||
var provider = GetActiveDownloadClient();
|
||||
|
||||
bool success = provider.DownloadNzb(parseResult.NzbUrl, GetDownloadTitle(parseResult));
|
||||
bool success = provider.DownloadNzb(parseResult.NzbUrl, downloadTitle);
|
||||
|
||||
if (success)
|
||||
{
|
||||
logger.Trace("Download added to Queue: {0}", downloadTitle);
|
||||
|
||||
foreach (var episode in _episodeProvider.GetEpisodesByParseResult(parseResult))
|
||||
foreach (var episode in parseResult.Episodes)
|
||||
{
|
||||
var history = new History
|
||||
{
|
||||
@ -115,7 +116,7 @@ public virtual String GetDownloadTitle(EpisodeParseResult parseResult)
|
||||
if (parseResult.Series.IsDaily)
|
||||
{
|
||||
var dailyResult = String.Format("{0} - {1:yyyy-MM-dd} - {2} [{3}]", seriesTitle,
|
||||
parseResult.AirDate, parseResult.EpisodeTitle, parseResult.Quality.Quality);
|
||||
parseResult.AirDate, parseResult.Episodes.First().Title, parseResult.Quality.Quality);
|
||||
|
||||
if (parseResult.Quality.Proper)
|
||||
dailyResult += " [Proper]";
|
||||
@ -126,15 +127,25 @@ public virtual String GetDownloadTitle(EpisodeParseResult parseResult)
|
||||
//Show Name - 1x01-1x02 - Episode Name
|
||||
//Show Name - 1x01 - Episode Name
|
||||
var episodeString = new List<String>();
|
||||
var episodeNames = new List<String>();
|
||||
|
||||
foreach (var episode in parseResult.EpisodeNumbers)
|
||||
foreach (var episode in parseResult.Episodes)
|
||||
{
|
||||
episodeString.Add(String.Format("{0}x{1:00}", parseResult.SeasonNumber, episode));
|
||||
episodeString.Add(String.Format("{0}x{1:00}", episode.SeasonNumber, episode.EpisodeNumber));
|
||||
episodeNames.Add(Parser.CleanupEpisodeTitle(episode.Title));
|
||||
}
|
||||
|
||||
var epNumberString = String.Join("-", episodeString);
|
||||
string episodeName;
|
||||
|
||||
var result = String.Format("{0} - {1} - {2} [{3}]", seriesTitle, epNumberString, parseResult.EpisodeTitle, parseResult.Quality.Quality);
|
||||
|
||||
if (episodeNames.Distinct().Count() == 1)
|
||||
episodeName = episodeNames.First();
|
||||
|
||||
else
|
||||
episodeName = String.Join(" + ", episodeNames.Distinct());
|
||||
|
||||
var result = String.Format("{0} - {1} - {2} [{3}]", seriesTitle, epNumberString, episodeName, parseResult.Quality.Quality);
|
||||
|
||||
if (parseResult.Quality.Proper)
|
||||
{
|
||||
|
@ -7,7 +7,7 @@
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Repository;
|
||||
using PetaPoco;
|
||||
using XemLib.Data;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
@ -188,11 +188,20 @@ public virtual IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseR
|
||||
|
||||
foreach (var episodeNumber in parseResult.EpisodeNumbers)
|
||||
{
|
||||
var episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber);
|
||||
Episode episodeInfo = null;
|
||||
|
||||
if (parseResult.SceneSource && parseResult.Series.UseSceneNumbering)
|
||||
episodeInfo = GetEpisodeBySceneNumbering(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber);
|
||||
|
||||
if (episodeInfo == null)
|
||||
{
|
||||
episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber);
|
||||
if (episodeInfo == null && parseResult.AirDate != null)
|
||||
{
|
||||
episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.AirDate.Value);
|
||||
}
|
||||
}
|
||||
|
||||
//if still null we should add the temp episode
|
||||
if (episodeInfo == null && autoAddNew)
|
||||
{
|
||||
@ -217,6 +226,16 @@ public virtual IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseR
|
||||
{
|
||||
result.Add(episodeInfo);
|
||||
|
||||
if (parseResult.Series.UseSceneNumbering)
|
||||
{
|
||||
logger.Info("Using Scene to TVDB Mapping for: {0} - Scene: {1}x{2:00} - TVDB: {3}x{4:00}",
|
||||
parseResult.Series.Title,
|
||||
episodeInfo.SceneSeasonNumber,
|
||||
episodeInfo.SceneEpisodeNumber,
|
||||
episodeInfo.SeasonNumber,
|
||||
episodeInfo.EpisodeNumber);
|
||||
}
|
||||
|
||||
if (parseResult.EpisodeNumbers.Count == 1)
|
||||
{
|
||||
parseResult.EpisodeTitle = episodeInfo.Title.Trim();
|
||||
@ -331,7 +350,7 @@ public virtual void RefreshEpisodeInfo(Series series)
|
||||
episodeToUpdate.TvDbEpisodeId = episode.Id;
|
||||
episodeToUpdate.EpisodeNumber = episode.EpisodeNumber;
|
||||
episodeToUpdate.SeasonNumber = episode.SeasonNumber;
|
||||
episodeToUpdate.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber;
|
||||
episodeToUpdate.AbsoluteEpisodeNumber = episode.AbsoluteNumber;
|
||||
episodeToUpdate.Title = episode.EpisodeName;
|
||||
|
||||
episodeToUpdate.Overview = episode.Overview.Truncate(3500);
|
||||
@ -435,5 +454,26 @@ public virtual void SetPostDownloadStatus(List<int> episodeIds, PostDownloadStat
|
||||
logger.Trace("Updating PostDownloadStatus for all episodeIds in {0}", episodeIdString);
|
||||
_database.Execute(episodeIdQuery);
|
||||
}
|
||||
|
||||
public virtual void UpdateEpisodes(List<Episode> episodes)
|
||||
{
|
||||
_database.UpdateMany(episodes);
|
||||
}
|
||||
|
||||
public virtual Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
var episode = _database.Fetch<Episode, Series, EpisodeFile>(@"SELECT * FROM Episodes
|
||||
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
|
||||
LEFT JOIN EpisodeFiles ON Episodes.EpisodeFileId = EpisodeFiles.EpisodeFileId
|
||||
WHERE Episodes.SeriesId = @0 AND Episodes.SceneSeasonNumber = @1 AND Episodes.SceneEpisodeNumber = @2", seriesId, seasonNumber, episodeNumber).SingleOrDefault();
|
||||
|
||||
if (episode == null)
|
||||
return null;
|
||||
|
||||
if (episode.EpisodeFileId == 0)
|
||||
episode.EpisodeFile = null;
|
||||
|
||||
return episode;
|
||||
}
|
||||
}
|
||||
} |