mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
moved naming specification out of general config.
This commit is contained in:
parent
db37d020f4
commit
dce64a5530
@ -14,6 +14,7 @@
|
|||||||
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
|
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
|
||||||
<DefaultTestTimeout>60000</DefaultTestTimeout>
|
<DefaultTestTimeout>60000</DefaultTestTimeout>
|
||||||
<UseBuildConfiguration></UseBuildConfiguration>
|
<UseBuildConfiguration></UseBuildConfiguration>
|
||||||
|
<UseBuildPlatform />
|
||||||
<ProxyProcessPath></ProxyProcessPath>
|
<ProxyProcessPath></ProxyProcessPath>
|
||||||
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
|
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
|
||||||
<IgnoredTests>
|
<IgnoredTests>
|
||||||
@ -32,5 +33,8 @@
|
|||||||
<NamedTestSelector>
|
<NamedTestSelector>
|
||||||
<TestName>NzbDrone.Common.Test.ServiceProviderTests.Should_be_able_to_start_and_stop_service</TestName>
|
<TestName>NzbDrone.Common.Test.ServiceProviderTests.Should_be_able_to_start_and_stop_service</TestName>
|
||||||
</NamedTestSelector>
|
</NamedTestSelector>
|
||||||
|
<RegexTestSelector>
|
||||||
|
<RegularExpression>.*</RegularExpression>
|
||||||
|
</RegexTestSelector>
|
||||||
</IgnoredTests>
|
</IgnoredTests>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@ -174,7 +174,7 @@ public void AutoIgnoreSeason_existing_should_not_ignore_currentseason()
|
|||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Setup(p => p.GetFilesBySeries(seriesId))
|
.Setup(p => p.GetFilesBySeries(seriesId))
|
||||||
.Returns(episodesFiles);
|
.Returns(episodesFiles.ToList());
|
||||||
|
|
||||||
Mocker.GetMock<ISeasonRepository>()
|
Mocker.GetMock<ISeasonRepository>()
|
||||||
.Setup(p => p.GetSeasonNumbers(seriesId))
|
.Setup(p => p.GetSeasonNumbers(seriesId))
|
||||||
@ -200,7 +200,7 @@ public void AutoIgnoreSeason_existing_should_ignore_seasons_with_no_file()
|
|||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Setup(p => p.GetFilesBySeries(seriesId))
|
.Setup(p => p.GetFilesBySeries(seriesId))
|
||||||
.Returns(episodesFiles);
|
.Returns(episodesFiles.ToList());
|
||||||
|
|
||||||
Mocker.GetMock<ISeasonRepository>()
|
Mocker.GetMock<ISeasonRepository>()
|
||||||
.Setup(p => p.GetSeasonNumbers(seriesId))
|
.Setup(p => p.GetSeasonNumbers(seriesId))
|
||||||
|
@ -44,7 +44,7 @@ public void Setup()
|
|||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Setup(s => s.GetFilesBySeason(_series.Id, 5))
|
.Setup(s => s.GetFilesBySeason(_series.Id, 5))
|
||||||
.Returns(_episodeFiles);
|
.Returns(_episodeFiles.ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WithMovedFiles()
|
private void WithMovedFiles()
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ public class MediaFileServiceTest : CoreTest<MediaFileService>
|
|||||||
[TestCase("Law & Order: Criminal Intent - S10E07 - Icarus [HDTV-720p]", "Law & Order- Criminal Intent - S10E07 - Icarus [HDTV-720p]")]
|
[TestCase("Law & Order: Criminal Intent - S10E07 - Icarus [HDTV-720p]", "Law & Order- Criminal Intent - S10E07 - Icarus [HDTV-720p]")]
|
||||||
public void CleanFileName(string name, string expectedName)
|
public void CleanFileName(string name, string expectedName)
|
||||||
{
|
{
|
||||||
MediaFileService.CleanFilename(name).Should().Be(expectedName);
|
FileNameBuilder.CleanFilename(name).Should().Be(expectedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -222,7 +222,7 @@
|
|||||||
<Compile Include="ProviderTests\DiskScanProviderTests\ImportFileFixture.cs" />
|
<Compile Include="ProviderTests\DiskScanProviderTests\ImportFileFixture.cs" />
|
||||||
<Compile Include="FluentTest.cs" />
|
<Compile Include="FluentTest.cs" />
|
||||||
<Compile Include="InstrumentationTests\DatabaseTargetFixture.cs" />
|
<Compile Include="InstrumentationTests\DatabaseTargetFixture.cs" />
|
||||||
<Compile Include="MediaFileTests\GetNewFilenameFixture.cs" />
|
<Compile Include="OrganizerTests\GetNewFilenameFixture.cs" />
|
||||||
<Compile Include="DecisionEngineTests\MonitoredEpisodeSpecificationFixture.cs" />
|
<Compile Include="DecisionEngineTests\MonitoredEpisodeSpecificationFixture.cs" />
|
||||||
<Compile Include="ProviderTests\DownloadProviderTests\DownloadProviderFixture.cs" />
|
<Compile Include="ProviderTests\DownloadProviderTests\DownloadProviderFixture.cs" />
|
||||||
<Compile Include="EpisodeStatusTest.cs" />
|
<Compile Include="EpisodeStatusTest.cs" />
|
||||||
|
@ -1,26 +1,28 @@
|
|||||||
// ReSharper disable RedundantUsingDirective
|
// ReSharper disable RedundantUsingDirective
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.MediaFileTests
|
namespace NzbDrone.Core.Test.OrganizerTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
public class MediaFileProvider_GetNewFilenameTest : CoreTest
|
public class MediaFileProvider_GetNewFilenameTest : CoreTest<FileNameBuilder>
|
||||||
{
|
{
|
||||||
private Series _series;
|
private Series _series;
|
||||||
|
|
||||||
|
private NameSpecification nameSpecification;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
@ -28,6 +30,15 @@ public void Setup()
|
|||||||
.CreateNew()
|
.CreateNew()
|
||||||
.With(s => s.Title = "South Park")
|
.With(s => s.Title = "South Park")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
|
nameSpecification = new NameSpecification();
|
||||||
|
|
||||||
|
|
||||||
|
Mocker.GetMock<IBasicRepository<NameSpecification>>()
|
||||||
|
.Setup(c => c.SingleOrDefault()).Returns(nameSpecification);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -36,13 +47,13 @@ public void GetNewFilename_Series_Episode_Quality_S01E05_Dash()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "City Sushi")
|
.With(e => e.Title = "City Sushi")
|
||||||
@ -51,7 +62,7 @@ public void GetNewFilename_Series_Episode_Quality_S01E05_Dash()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("South Park - S15E06 - City Sushi [HDTV-720p]", result);
|
Assert.AreEqual("South Park - S15E06 - City Sushi [HDTV-720p]", result);
|
||||||
@ -63,13 +74,13 @@ public void GetNewFilename_Episode_Quality_1x05_Dash()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
nameSpecification.SortingIncludeSeriesName = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
nameSpecification.SortingNumberStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "City Sushi")
|
.With(e => e.Title = "City Sushi")
|
||||||
@ -78,7 +89,7 @@ public void GetNewFilename_Episode_Quality_1x05_Dash()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("15x06 - City Sushi [HDTV-720p]", result);
|
Assert.AreEqual("15x06 - City Sushi [HDTV-720p]", result);
|
||||||
@ -90,13 +101,13 @@ public void GetNewFilename_Series_Quality_01x05_Space()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
nameSpecification.SortingIncludeEpisodeTitle = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(1);
|
nameSpecification.SortingSeparatorStyle = 1;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(1);
|
nameSpecification.SortingNumberStyle = 1;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "City Sushi")
|
.With(e => e.Title = "City Sushi")
|
||||||
@ -105,7 +116,7 @@ public void GetNewFilename_Series_Quality_01x05_Space()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("South Park 05x06 [HDTV-720p]", result);
|
Assert.AreEqual("South Park 05x06 [HDTV-720p]", result);
|
||||||
@ -117,13 +128,13 @@ public void GetNewFilename_Series_s01e05_Space()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
nameSpecification.SortingIncludeEpisodeTitle = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(1);
|
nameSpecification.SortingSeparatorStyle = 1;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(3);
|
nameSpecification.SortingNumberStyle = 3;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
@ -133,7 +144,7 @@ public void GetNewFilename_Series_s01e05_Space()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("South Park s05e06", result);
|
Assert.AreEqual("South Park s05e06", result);
|
||||||
@ -145,13 +156,13 @@ public void GetNewFilename_Series_Episode_s01e05_Periods()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(1);
|
nameSpecification.SortingSeparatorStyle = 1;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(3);
|
nameSpecification.SortingNumberStyle = 3;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(true);
|
nameSpecification.SortingReplaceSpaces = true;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "City Sushi")
|
.With(e => e.Title = "City Sushi")
|
||||||
@ -160,7 +171,7 @@ public void GetNewFilename_Series_Episode_s01e05_Periods()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("South.Park.s05e06.City.Sushi", result);
|
Assert.AreEqual("South.Park.s05e06.City.Sushi", result);
|
||||||
@ -172,13 +183,13 @@ public void GetNewFilename_Series_Episode_s01e05_Dash_Periods_Quality()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(3);
|
nameSpecification.SortingNumberStyle = 3;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(true);
|
nameSpecification.SortingReplaceSpaces = true;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "City Sushi")
|
.With(e => e.Title = "City Sushi")
|
||||||
@ -187,7 +198,7 @@ public void GetNewFilename_Series_Episode_s01e05_Dash_Periods_Quality()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("South.Park.-.s05e06.-.City.Sushi.[HDTV-720p]", result);
|
Assert.AreEqual("South.Park.-.s05e06.-.City.Sushi.[HDTV-720p]", result);
|
||||||
@ -199,13 +210,13 @@ public void GetNewFilename_S01E05_Dash()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
nameSpecification.SortingIncludeSeriesName = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
nameSpecification.SortingIncludeEpisodeTitle = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
@ -215,7 +226,7 @@ public void GetNewFilename_S01E05_Dash()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("S15E06", result);
|
Assert.AreEqual("S15E06", result);
|
||||||
@ -227,14 +238,14 @@ public void GetNewFilename_multi_Series_Episode_Quality_S01E05_Scene_Dash()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
|
nameSpecification.SortingMultiEpisodeStyle = 3;
|
||||||
|
|
||||||
var episodeOne = Builder<Episode>.CreateNew()
|
var episodeOne = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "Strawberries and Cream (1)")
|
.With(e => e.Title = "Strawberries and Cream (1)")
|
||||||
@ -249,7 +260,7 @@ public void GetNewFilename_multi_Series_Episode_Quality_S01E05_Scene_Dash()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("The Mentalist - S03E23-E24 - Strawberries and Cream [HDTV-720p]", result);
|
Assert.AreEqual("The Mentalist - S03E23-E24 - Strawberries and Cream [HDTV-720p]", result);
|
||||||
@ -261,14 +272,14 @@ public void GetNewFilename_multi_Episode_Quality_1x05_Repeat_Dash()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
nameSpecification.SortingIncludeSeriesName = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
nameSpecification.SortingNumberStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(2);
|
nameSpecification.SortingMultiEpisodeStyle = 2;
|
||||||
|
|
||||||
var episodeOne = Builder<Episode>.CreateNew()
|
var episodeOne = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "Strawberries and Cream (1)")
|
.With(e => e.Title = "Strawberries and Cream (1)")
|
||||||
@ -283,7 +294,7 @@ public void GetNewFilename_multi_Episode_Quality_1x05_Repeat_Dash()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("3x23x24 - Strawberries and Cream [HDTV-720p]", result);
|
Assert.AreEqual("3x23x24 - Strawberries and Cream [HDTV-720p]", result);
|
||||||
@ -295,14 +306,14 @@ public void GetNewFilename_multi_Episode_Quality_01x05_Repeat_Space()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
nameSpecification.SortingIncludeSeriesName = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(1);
|
nameSpecification.SortingSeparatorStyle = 1;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
nameSpecification.SortingNumberStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(2);
|
nameSpecification.SortingMultiEpisodeStyle = 2;
|
||||||
|
|
||||||
var episodeOne = Builder<Episode>.CreateNew()
|
var episodeOne = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "Strawberries and Cream (1)")
|
.With(e => e.Title = "Strawberries and Cream (1)")
|
||||||
@ -317,7 +328,7 @@ public void GetNewFilename_multi_Episode_Quality_01x05_Repeat_Space()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("3x23x24 Strawberries and Cream [HDTV-720p]", result);
|
Assert.AreEqual("3x23x24 Strawberries and Cream [HDTV-720p]", result);
|
||||||
@ -329,14 +340,14 @@ public void GetNewFilename_multi_Series_Episode_s01e05_Duplicate_Period()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(1);
|
nameSpecification.SortingSeparatorStyle = 1;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(3);
|
nameSpecification.SortingNumberStyle = 3;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(true);
|
nameSpecification.SortingReplaceSpaces = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(1);
|
nameSpecification.SortingMultiEpisodeStyle = 1;
|
||||||
|
|
||||||
var episodeOne = Builder<Episode>.CreateNew()
|
var episodeOne = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "Strawberries and Cream (1)")
|
.With(e => e.Title = "Strawberries and Cream (1)")
|
||||||
@ -351,7 +362,7 @@ public void GetNewFilename_multi_Series_Episode_s01e05_Duplicate_Period()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("The.Mentalist.s03e23.s03e24.Strawberries.and.Cream", result);
|
Assert.AreEqual("The.Mentalist.s03e23.s03e24.Strawberries.and.Cream", result);
|
||||||
@ -363,14 +374,14 @@ public void GetNewFilename_multi_Series_S01E05_Extend_Dash_Period()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
nameSpecification.SortingIncludeEpisodeTitle = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(true);
|
nameSpecification.SortingReplaceSpaces = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(0);
|
nameSpecification.SortingMultiEpisodeStyle = 0;
|
||||||
|
|
||||||
var episodeOne = Builder<Episode>.CreateNew()
|
var episodeOne = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "Strawberries and Cream (1)")
|
.With(e => e.Title = "Strawberries and Cream (1)")
|
||||||
@ -385,7 +396,7 @@ public void GetNewFilename_multi_Series_S01E05_Extend_Dash_Period()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("The.Mentalist.-.S03E23-24", result);
|
Assert.AreEqual("The.Mentalist.-.S03E23-24", result);
|
||||||
@ -397,14 +408,14 @@ public void GetNewFilename_multi_1x05_Repeat_Dash_Period()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
nameSpecification.SortingIncludeSeriesName = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
nameSpecification.SortingIncludeEpisodeTitle = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
nameSpecification.SortingNumberStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(true);
|
nameSpecification.SortingReplaceSpaces = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(2);
|
nameSpecification.SortingMultiEpisodeStyle = 2;
|
||||||
|
|
||||||
var episodeOne = Builder<Episode>.CreateNew()
|
var episodeOne = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "Strawberries and Cream (1)")
|
.With(e => e.Title = "Strawberries and Cream (1)")
|
||||||
@ -419,7 +430,7 @@ public void GetNewFilename_multi_1x05_Repeat_Dash_Period()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("3x23x24", result);
|
Assert.AreEqual("3x23x24", result);
|
||||||
@ -429,13 +440,13 @@ public void GetNewFilename_multi_1x05_Repeat_Dash_Period()
|
|||||||
public void GetNewFilename_should_append_proper_when_proper_and_append_quality_is_true()
|
public void GetNewFilename_should_append_proper_when_proper_and_append_quality_is_true()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "City Sushi")
|
.With(e => e.Title = "City Sushi")
|
||||||
@ -444,7 +455,7 @@ public void GetNewFilename_should_append_proper_when_proper_and_append_quality_i
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, true, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, true, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p] [Proper]");
|
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p] [Proper]");
|
||||||
@ -454,13 +465,13 @@ public void GetNewFilename_should_append_proper_when_proper_and_append_quality_i
|
|||||||
public void GetNewFilename_should_not_append_proper_when_not_proper_and_append_quality_is_true()
|
public void GetNewFilename_should_not_append_proper_when_not_proper_and_append_quality_is_true()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "City Sushi")
|
.With(e => e.Title = "City Sushi")
|
||||||
@ -469,7 +480,7 @@ public void GetNewFilename_should_not_append_proper_when_not_proper_and_append_q
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p]");
|
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p]");
|
||||||
@ -479,13 +490,13 @@ public void GetNewFilename_should_not_append_proper_when_not_proper_and_append_q
|
|||||||
public void GetNewFilename_should_not_append_proper_when_proper_and_append_quality_is_false()
|
public void GetNewFilename_should_not_append_proper_when_proper_and_append_quality_is_false()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "City Sushi")
|
.With(e => e.Title = "City Sushi")
|
||||||
@ -494,7 +505,7 @@ public void GetNewFilename_should_not_append_proper_when_proper_and_append_quali
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, true, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, true, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().Be("South Park - S15E06 - City Sushi");
|
result.Should().Be("South Park - S15E06 - City Sushi");
|
||||||
@ -504,14 +515,14 @@ public void GetNewFilename_should_not_append_proper_when_proper_and_append_quali
|
|||||||
public void GetNewFilename_should_order_multiple_episode_files_in_numerical_order()
|
public void GetNewFilename_should_order_multiple_episode_files_in_numerical_order()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
|
nameSpecification.SortingMultiEpisodeStyle = 3;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "Hey, Baby, What's Wrong? (1)")
|
.With(e => e.Title = "Hey, Baby, What's Wrong? (1)")
|
||||||
@ -526,7 +537,7 @@ public void GetNewFilename_should_order_multiple_episode_files_in_numerical_orde
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
|
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
|
||||||
@ -538,13 +549,13 @@ public void GetNewFilename_Series_Episode_Quality_S01E05_Period()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(2);
|
nameSpecification.SortingSeparatorStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "City Sushi")
|
.With(e => e.Title = "City Sushi")
|
||||||
@ -553,7 +564,7 @@ public void GetNewFilename_Series_Episode_Quality_S01E05_Period()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("South Park.S15E06.City Sushi [HDTV-720p]", result);
|
Assert.AreEqual("South Park.S15E06.City Sushi [HDTV-720p]", result);
|
||||||
@ -565,13 +576,13 @@ public void GetNewFilename_Episode_Quality_1x05_Period()
|
|||||||
//Setup
|
//Setup
|
||||||
|
|
||||||
|
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
nameSpecification.SortingIncludeSeriesName = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(2);
|
nameSpecification.SortingSeparatorStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
nameSpecification.SortingNumberStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "City Sushi")
|
.With(e => e.Title = "City Sushi")
|
||||||
@ -580,7 +591,7 @@ public void GetNewFilename_Episode_Quality_1x05_Period()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual("15x06.City Sushi [HDTV-720p]", result);
|
Assert.AreEqual("15x06.City Sushi [HDTV-720p]", result);
|
||||||
@ -590,14 +601,14 @@ public void GetNewFilename_Episode_Quality_1x05_Period()
|
|||||||
public void GetNewFilename_UseSceneName_when_sceneName_isNull()
|
public void GetNewFilename_UseSceneName_when_sceneName_isNull()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
nameSpecification.SortingIncludeSeriesName = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(2);
|
nameSpecification.SortingSeparatorStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
nameSpecification.SortingNumberStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingUseSceneName).Returns(true);
|
nameSpecification.SortingUseSceneName = true;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "City Sushi")
|
.With(e => e.Title = "City Sushi")
|
||||||
@ -611,7 +622,7 @@ public void GetNewFilename_UseSceneName_when_sceneName_isNull()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, episodeFile);
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, episodeFile);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().Be(Path.GetFileNameWithoutExtension(episodeFile.Path));
|
result.Should().Be(Path.GetFileNameWithoutExtension(episodeFile.Path));
|
||||||
@ -621,14 +632,14 @@ public void GetNewFilename_UseSceneName_when_sceneName_isNull()
|
|||||||
public void GetNewFilename_UseSceneName_when_sceneName_isNotNull()
|
public void GetNewFilename_UseSceneName_when_sceneName_isNotNull()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
nameSpecification.SortingIncludeSeriesName = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(2);
|
nameSpecification.SortingSeparatorStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
nameSpecification.SortingNumberStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingUseSceneName).Returns(true);
|
nameSpecification.SortingUseSceneName = true;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "City Sushi")
|
.With(e => e.Title = "City Sushi")
|
||||||
@ -642,7 +653,7 @@ public void GetNewFilename_UseSceneName_when_sceneName_isNotNull()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, episodeFile);
|
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, episodeFile);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().Be(episodeFile.SceneName);
|
result.Should().Be(episodeFile.SceneName);
|
||||||
@ -652,14 +663,14 @@ public void GetNewFilename_UseSceneName_when_sceneName_isNotNull()
|
|||||||
public void should_only_have_one_episodeTitle_when_episode_titles_are_the_same()
|
public void should_only_have_one_episodeTitle_when_episode_titles_are_the_same()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
|
nameSpecification.SortingMultiEpisodeStyle = 3;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "Hey, Baby, What's Wrong? (1)")
|
.With(e => e.Title = "Hey, Baby, What's Wrong? (1)")
|
||||||
@ -674,7 +685,7 @@ public void should_only_have_one_episodeTitle_when_episode_titles_are_the_same()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
|
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
|
||||||
@ -684,14 +695,14 @@ public void should_only_have_one_episodeTitle_when_episode_titles_are_the_same()
|
|||||||
public void should_have_two_episodeTitles_when_episode_titles_are_not_the_same()
|
public void should_have_two_episodeTitles_when_episode_titles_are_not_the_same()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
|
nameSpecification.SortingMultiEpisodeStyle = 3;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "Hello")
|
.With(e => e.Title = "Hello")
|
||||||
@ -706,7 +717,7 @@ public void should_have_two_episodeTitles_when_episode_titles_are_not_the_same()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().Be("30 Rock - S06E06-E07 - Hello + World");
|
result.Should().Be("30 Rock - S06E06-E07 - Hello + World");
|
||||||
@ -716,14 +727,14 @@ public void should_have_two_episodeTitles_when_episode_titles_are_not_the_same()
|
|||||||
public void should_have_two_episodeTitles_when_distinct_count_is_two()
|
public void should_have_two_episodeTitles_when_distinct_count_is_two()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
|
nameSpecification.SortingMultiEpisodeStyle = 3;
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
var episode = Builder<Episode>.CreateNew()
|
||||||
.With(e => e.Title = "Hello (3)")
|
.With(e => e.Title = "Hello (3)")
|
||||||
@ -744,7 +755,7 @@ public void should_have_two_episodeTitles_when_distinct_count_is_two()
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
string result = Mocker.Resolve<IMediaFileService>().GetNewFilename(new List<Episode> { episode, episode2, episode3 }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
|
string result = Subject.GetNewFilename(new List<Episode> { episode, episode2, episode3 }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().Be("30 Rock - S06E06-E07-E08 - Hello + World");
|
result.Should().Be("30 Rock - S06E06-E07-E08 - Hello + World");
|
||||||
@ -753,13 +764,13 @@ public void should_have_two_episodeTitles_when_distinct_count_is_two()
|
|||||||
[Test]
|
[Test]
|
||||||
public void should_use_airDate_if_series_isDaily()
|
public void should_use_airDate_if_series_isDaily()
|
||||||
{
|
{
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
nameSpecification.SortingAppendQuality = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
var series = Builder<Series>
|
var series = Builder<Series>
|
||||||
.CreateNew()
|
.CreateNew()
|
||||||
@ -774,7 +785,7 @@ public void should_use_airDate_if_series_isDaily()
|
|||||||
.With(e => e.Title = "Kristen Stewart")
|
.With(e => e.Title = "Kristen Stewart")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var result = Mocker.Resolve<IMediaFileService>()
|
var result = Subject
|
||||||
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
|
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13 - Kristen Stewart [HDTV-720p]");
|
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13 - Kristen Stewart [HDTV-720p]");
|
||||||
}
|
}
|
||||||
@ -782,13 +793,13 @@ public void should_use_airDate_if_series_isDaily()
|
|||||||
[Test]
|
[Test]
|
||||||
public void should_use_airDate_if_series_isDaily_no_episode_title()
|
public void should_use_airDate_if_series_isDaily_no_episode_title()
|
||||||
{
|
{
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
nameSpecification.SortingIncludeEpisodeTitle = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
var series = Builder<Series>
|
var series = Builder<Series>
|
||||||
.CreateNew()
|
.CreateNew()
|
||||||
@ -803,7 +814,7 @@ public void should_use_airDate_if_series_isDaily_no_episode_title()
|
|||||||
.With(e => e.Title = "Kristen Stewart")
|
.With(e => e.Title = "Kristen Stewart")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var result = Mocker.Resolve<IMediaFileService>()
|
var result = Subject
|
||||||
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
|
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13");
|
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13");
|
||||||
}
|
}
|
||||||
@ -811,13 +822,13 @@ public void should_use_airDate_if_series_isDaily_no_episode_title()
|
|||||||
[Test]
|
[Test]
|
||||||
public void should_set_airdate_to_unknown_if_not_available()
|
public void should_set_airdate_to_unknown_if_not_available()
|
||||||
{
|
{
|
||||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
nameSpecification.SortingIncludeSeriesName = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
nameSpecification.SortingAppendQuality = false;
|
||||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
nameSpecification.SortingSeparatorStyle = 0;
|
||||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
nameSpecification.SortingNumberStyle = 2;
|
||||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
nameSpecification.SortingReplaceSpaces = false;
|
||||||
|
|
||||||
var series = Builder<Series>
|
var series = Builder<Series>
|
||||||
.CreateNew()
|
.CreateNew()
|
||||||
@ -832,7 +843,7 @@ public void should_set_airdate_to_unknown_if_not_available()
|
|||||||
.With(e => e.Title = "Kristen Stewart")
|
.With(e => e.Title = "Kristen Stewart")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var result = Mocker.Resolve<IMediaFileService>()
|
var result = Subject
|
||||||
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
|
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
|
||||||
result.Should().Be("The Daily Show with Jon Stewart - Unknown - Kristen Stewart");
|
result.Should().Be("The Daily Show with Jon Stewart - Unknown - Kristen Stewart");
|
||||||
}
|
}
|
@ -9,6 +9,7 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
@ -106,10 +107,10 @@ public void should_move_file_if_a_conflict_is_found()
|
|||||||
Mocker.GetMock<IEpisodeService>().Setup(s => s.GetEpisodesByFileId(episodeFile.Id))
|
Mocker.GetMock<IEpisodeService>().Setup(s => s.GetEpisodesByFileId(episodeFile.Id))
|
||||||
.Returns(episode);
|
.Returns(episode);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Setup(s => s.GetNewFilename(It.IsAny<IList<Episode>>(), series, Quality.Unknown, false, It.IsAny<EpisodeFile>()))
|
Mocker.GetMock<IBuildFileNames>().Setup(s => s.GetNewFilename(It.IsAny<IList<Episode>>(), series, Quality.Unknown, false, It.IsAny<EpisodeFile>()))
|
||||||
.Returns(newFilename);
|
.Returns(newFilename);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Setup(s => s.CalculateFilePath(It.IsAny<Series>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()))
|
Mocker.GetMock<IBuildFileNames>().Setup(s => s.CalculateFilePath(It.IsAny<Series>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||||
.Returns(new FileInfo(newFilePath));
|
.Returns(new FileInfo(newFilePath));
|
||||||
|
|
||||||
Mocker.GetMock<DiskProvider>()
|
Mocker.GetMock<DiskProvider>()
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.ExternalNotification;
|
using NzbDrone.Core.ExternalNotification;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
@ -56,11 +57,11 @@ public void should_not_move_file_if_source_and_destination_are_the_same_path()
|
|||||||
.Setup(e => e.GetEpisodesByFileId(file.Id))
|
.Setup(e => e.GetEpisodesByFileId(file.Id))
|
||||||
.Returns(fakeEpisode);
|
.Returns(fakeEpisode);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
|
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
|
||||||
.Returns(filename);
|
.Returns(filename);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".avi"))
|
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".avi"))
|
||||||
.Returns(fi);
|
.Returns(fi);
|
||||||
|
|
||||||
@ -106,11 +107,11 @@ public void should_use_EpisodeFiles_quality()
|
|||||||
.Setup(e => e.GetEpisodesByFileId(file.Id))
|
.Setup(e => e.GetEpisodesByFileId(file.Id))
|
||||||
.Returns(fakeEpisode);
|
.Returns(fakeEpisode);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
|
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
|
||||||
.Returns(filename);
|
.Returns(filename);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
|
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
|
||||||
.Returns(fi);
|
.Returns(fi);
|
||||||
|
|
||||||
@ -158,11 +159,11 @@ public void should_log_error_and_return_null_when_source_file_does_not_exists()
|
|||||||
.Setup(e => e.GetEpisodesByFileId(file.Id))
|
.Setup(e => e.GetEpisodesByFileId(file.Id))
|
||||||
.Returns(fakeEpisode);
|
.Returns(fakeEpisode);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
|
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
|
||||||
.Returns(filename);
|
.Returns(filename);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
|
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
|
||||||
.Returns(fi);
|
.Returns(fi);
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
@ -48,11 +49,11 @@ public void no_misnamed_files()
|
|||||||
Mocker.GetMock<IEpisodeService>()
|
Mocker.GetMock<IEpisodeService>()
|
||||||
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
|
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
|
||||||
.Returns("Title1");
|
.Returns("Title1");
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
|
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
|
||||||
.Returns("Title2");
|
.Returns("Title2");
|
||||||
|
|
||||||
@ -95,11 +96,11 @@ public void all_misnamed_files()
|
|||||||
Mocker.GetMock<IEpisodeService>()
|
Mocker.GetMock<IEpisodeService>()
|
||||||
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
|
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
|
||||||
.Returns("New Title 1");
|
.Returns("New Title 1");
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
|
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
|
||||||
.Returns("New Title 2");
|
.Returns("New Title 2");
|
||||||
|
|
||||||
@ -142,11 +143,11 @@ public void one_misnamed_file()
|
|||||||
Mocker.GetMock<IEpisodeService>()
|
Mocker.GetMock<IEpisodeService>()
|
||||||
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
|
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
|
||||||
.Returns("New Title 1");
|
.Returns("New Title 1");
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
|
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
|
||||||
.Returns("Title2");
|
.Returns("Title2");
|
||||||
|
|
||||||
@ -191,11 +192,11 @@ public void misnamed_multi_episode_file()
|
|||||||
Mocker.GetMock<IEpisodeService>()
|
Mocker.GetMock<IEpisodeService>()
|
||||||
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
|
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
|
||||||
.Returns("New Title 1");
|
.Returns("New Title 1");
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
|
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
|
||||||
.Returns("Title2");
|
.Returns("Title2");
|
||||||
|
|
||||||
@ -240,11 +241,11 @@ public void no_misnamed_multi_episode_file()
|
|||||||
Mocker.GetMock<IEpisodeService>()
|
Mocker.GetMock<IEpisodeService>()
|
||||||
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
|
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
|
||||||
.Returns("Title1");
|
.Returns("Title1");
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IBuildFileNames>()
|
||||||
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
|
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
|
||||||
.Returns("Title2");
|
.Returns("Title2");
|
||||||
|
|
||||||
|
@ -149,29 +149,6 @@ public String DownloadClientTvDirectory
|
|||||||
set { SetValue("DownloadClientTvDirectory", value); }
|
set { SetValue("DownloadClientTvDirectory", value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SortingIncludeSeriesName
|
|
||||||
{
|
|
||||||
get { return GetValueBoolean("Sorting_SeriesName", true); }
|
|
||||||
set { SetValue("Sorting_SeriesName", value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SortingIncludeEpisodeTitle
|
|
||||||
{
|
|
||||||
get { return GetValueBoolean("Sorting_EpisodeName", true); }
|
|
||||||
set { SetValue("Sorting_EpisodeName", value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SortingReplaceSpaces
|
|
||||||
{
|
|
||||||
get { return GetValueBoolean("Sorting_ReplaceSpaces"); }
|
|
||||||
set { SetValue("Sorting_ReplaceSpaces", value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SortingAppendQuality
|
|
||||||
{
|
|
||||||
get { return GetValueBoolean("Sorting_AppendQaulity", true); }
|
|
||||||
set { SetValue("Sorting_AppendQaulity", value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool UseSeasonFolder
|
public bool UseSeasonFolder
|
||||||
{
|
{
|
||||||
@ -186,30 +163,6 @@ public string SortingSeasonFolderFormat
|
|||||||
set { SetValue("Sorting_SeasonFolderFormat", value); }
|
set { SetValue("Sorting_SeasonFolderFormat", value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int SortingSeparatorStyle
|
|
||||||
{
|
|
||||||
get { return GetValueInt("Sorting_SeparatorStyle"); }
|
|
||||||
set { SetValue("Sorting_SeparatorStyle", value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public int SortingNumberStyle
|
|
||||||
{
|
|
||||||
get { return GetValueInt("Sorting_NumberStyle", 2); }
|
|
||||||
set { SetValue("Sorting_NumberStyle", value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public int SortingMultiEpisodeStyle
|
|
||||||
{
|
|
||||||
get { return GetValueInt("Sorting_MultiEpisodeStyle"); }
|
|
||||||
set { SetValue("Sorting_MultiEpisodeStyle", value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SortingUseSceneName
|
|
||||||
{
|
|
||||||
get { return GetValueBoolean("Sorting_UseSceneName", false); }
|
|
||||||
set { SetValue("Sorting_UseSceneName", value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public int DefaultQualityProfile
|
public int DefaultQualityProfile
|
||||||
{
|
{
|
||||||
get { return GetValueInt("DefaultQualityProfile", 1); }
|
get { return GetValueInt("DefaultQualityProfile", 1); }
|
||||||
|
@ -25,16 +25,8 @@ public interface IConfigService
|
|||||||
SabPriorityType SabBacklogTvPriority { get; set; }
|
SabPriorityType SabBacklogTvPriority { get; set; }
|
||||||
SabPriorityType SabRecentTvPriority { get; set; }
|
SabPriorityType SabRecentTvPriority { get; set; }
|
||||||
String DownloadClientTvDirectory { get; set; }
|
String DownloadClientTvDirectory { get; set; }
|
||||||
bool SortingIncludeSeriesName { get; set; }
|
|
||||||
bool SortingIncludeEpisodeTitle { get; set; }
|
|
||||||
bool SortingReplaceSpaces { get; set; }
|
|
||||||
bool SortingAppendQuality { get; set; }
|
|
||||||
bool UseSeasonFolder { get; set; }
|
bool UseSeasonFolder { get; set; }
|
||||||
string SortingSeasonFolderFormat { get; set; }
|
string SortingSeasonFolderFormat { get; set; }
|
||||||
int SortingSeparatorStyle { get; set; }
|
|
||||||
int SortingNumberStyle { get; set; }
|
|
||||||
int SortingMultiEpisodeStyle { get; set; }
|
|
||||||
bool SortingUseSceneName { get; set; }
|
|
||||||
int DefaultQualityProfile { get; set; }
|
int DefaultQualityProfile { get; set; }
|
||||||
Boolean XbmcUpdateLibrary { get; set; }
|
Boolean XbmcUpdateLibrary { get; set; }
|
||||||
Boolean XbmcCleanLibrary { get; set; }
|
Boolean XbmcCleanLibrary { get; set; }
|
||||||
|
@ -8,13 +8,15 @@ namespace NzbDrone.Core.Datastore
|
|||||||
IEnumerable<TModel> All();
|
IEnumerable<TModel> All();
|
||||||
int Count();
|
int Count();
|
||||||
TModel Get(int id);
|
TModel Get(int id);
|
||||||
|
TModel Single();
|
||||||
|
TModel SingleOrDefault();
|
||||||
TModel Insert(TModel model);
|
TModel Insert(TModel model);
|
||||||
TModel Update(TModel model);
|
TModel Update(TModel model);
|
||||||
TModel Upsert(TModel model);
|
TModel UpSert(TModel model);
|
||||||
void Delete(int id);
|
void Delete(int id);
|
||||||
IList<TModel> InsertMany(IList<TModel> model);
|
IList<TModel> InsertMany(IList<TModel> model);
|
||||||
IList<TModel> UpdateMany(IList<TModel> model);
|
IList<TModel> UpdateMany(IList<TModel> model);
|
||||||
void DeleteMany(IList<TModel> model);
|
void DeleteMany(List<TModel> model);
|
||||||
void Purge();
|
void Purge();
|
||||||
bool HasItems();
|
bool HasItems();
|
||||||
}
|
}
|
||||||
@ -45,6 +47,16 @@ public TModel Get(int id)
|
|||||||
return Queryable.Single(c => c.Id == id);
|
return Queryable.Single(c => c.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TModel Single()
|
||||||
|
{
|
||||||
|
return Queryable.Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TModel SingleOrDefault()
|
||||||
|
{
|
||||||
|
return Queryable.SingleOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
public TModel Insert(TModel model)
|
public TModel Insert(TModel model)
|
||||||
{
|
{
|
||||||
return ObjectDatabase.Insert(model);
|
return ObjectDatabase.Insert(model);
|
||||||
@ -65,12 +77,12 @@ public IList<TModel> UpdateMany(IList<TModel> model)
|
|||||||
return ObjectDatabase.UpdateMany(model);
|
return ObjectDatabase.UpdateMany(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteMany(IList<TModel> model)
|
public void DeleteMany(List<TModel> model)
|
||||||
{
|
{
|
||||||
ObjectDatabase.DeleteMany(model);
|
ObjectDatabase.DeleteMany(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TModel Upsert(TModel model)
|
public TModel UpSert(TModel model)
|
||||||
{
|
{
|
||||||
if (model.Id == 0)
|
if (model.Id == 0)
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Organizer;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Download.Clients
|
namespace NzbDrone.Core.Download.Clients
|
||||||
{
|
{
|
||||||
@ -37,7 +38,7 @@ public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
title = MediaFileService.CleanFilename(title);
|
title = FileNameBuilder.CleanFilename(title);
|
||||||
|
|
||||||
var filename = Path.Combine(_configService.BlackholeDirectory, title + ".nzb");
|
var filename = Path.Combine(_configService.BlackholeDirectory, title + ".nzb");
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Organizer;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Download.Clients
|
namespace NzbDrone.Core.Download.Clients
|
||||||
{
|
{
|
||||||
@ -43,7 +44,7 @@ public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
title = MediaFileService.CleanFilename(title);
|
title = FileNameBuilder.CleanFilename(title);
|
||||||
|
|
||||||
//Save to the Pneumatic directory (The user will need to ensure its accessible by XBMC)
|
//Save to the Pneumatic directory (The user will need to ensure its accessible by XBMC)
|
||||||
var filename = Path.Combine(_configService.PneumaticDirectory, title + ".nzb");
|
var filename = Path.Combine(_configService.PneumaticDirectory, title + ".nzb");
|
||||||
|
@ -65,7 +65,7 @@ private void SetEnableStatus(Action<ExternalNotificationDefinition> updateAction
|
|||||||
new ExternalNotificationDefinition { Name = Name };
|
new ExternalNotificationDefinition { Name = Name };
|
||||||
|
|
||||||
updateAction(def);
|
updateAction(def);
|
||||||
_externalNotificationRepository.Upsert(def);
|
_externalNotificationRepository.UpSert(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool GetEnableStatus(Func<ExternalNotificationDefinition, bool> readFunction)
|
private bool GetEnableStatus(Func<ExternalNotificationDefinition, bool> readFunction)
|
||||||
|
@ -67,7 +67,7 @@ public void SaveSettings(Indexer indexer)
|
|||||||
{
|
{
|
||||||
//Todo: This will be used in the API
|
//Todo: This will be used in the API
|
||||||
_logger.Debug("Upserting Indexer definitions for {0}", indexer.Name);
|
_logger.Debug("Upserting Indexer definitions for {0}", indexer.Name);
|
||||||
_indexerRepository.Upsert(indexer);
|
_indexerRepository.UpSert(indexer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Indexer GetSettings(Type type)
|
public Indexer GetSettings(Type type)
|
||||||
|
@ -68,7 +68,7 @@ public void Init()
|
|||||||
|
|
||||||
jobDefinition.Interval = Convert.ToInt32(job.DefaultInterval.TotalMinutes);
|
jobDefinition.Interval = Convert.ToInt32(job.DefaultInterval.TotalMinutes);
|
||||||
|
|
||||||
Upsert(jobDefinition);
|
UpSert(jobDefinition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Eventing;
|
using NzbDrone.Common.Eventing;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Qualities;
|
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Helpers;
|
|
||||||
using NzbDrone.Core.Tv.Events;
|
using NzbDrone.Core.Tv.Events;
|
||||||
|
|
||||||
namespace NzbDrone.Core.MediaFiles
|
namespace NzbDrone.Core.MediaFiles
|
||||||
@ -19,10 +15,8 @@ public interface IMediaFileService
|
|||||||
void Delete(int episodeFileId);
|
void Delete(int episodeFileId);
|
||||||
bool Exists(string path);
|
bool Exists(string path);
|
||||||
EpisodeFile GetFileByPath(string path);
|
EpisodeFile GetFileByPath(string path);
|
||||||
IList<EpisodeFile> GetFilesBySeries(int seriesId);
|
List<EpisodeFile> GetFilesBySeries(int seriesId);
|
||||||
IList<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber);
|
List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber);
|
||||||
FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extention);
|
|
||||||
string GetNewFilename(IList<Episode> episodes, Series series, Quality quality, bool proper, EpisodeFile episodeFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MediaFileService : IMediaFileService, IHandleAsync<SeriesDeletedEvent>
|
public class MediaFileService : IMediaFileService, IHandleAsync<SeriesDeletedEvent>
|
||||||
@ -73,25 +67,32 @@ public EpisodeFile GetFileByPath(string path)
|
|||||||
return _mediaFileRepository.GetFileByPath(path.Normalize());
|
return _mediaFileRepository.GetFileByPath(path.Normalize());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<EpisodeFile> GetFilesBySeries(int seriesId)
|
public List<EpisodeFile> GetFilesBySeries(int seriesId)
|
||||||
{
|
{
|
||||||
return _mediaFileRepository.GetFilesBySeries(seriesId);
|
return _mediaFileRepository.GetFilesBySeries(seriesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber)
|
public List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber)
|
||||||
{
|
{
|
||||||
return _mediaFileRepository.GetFilesBySeason(seriesId, seasonNumber);
|
return _mediaFileRepository.GetFilesBySeason(seriesId, seasonNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void HandleAsync(SeriesDeletedEvent message)
|
||||||
|
{
|
||||||
|
var files = GetFilesBySeries(message.Series.Id);
|
||||||
|
_mediaFileRepository.DeleteMany(files);
|
||||||
|
}
|
||||||
|
|
||||||
public FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extention)
|
public FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extention)
|
||||||
{
|
{
|
||||||
string path = series.Path;
|
string path = series.Path;
|
||||||
if (series.SeasonFolder)
|
if (series.SeasonFolder)
|
||||||
{
|
{
|
||||||
var seasonFolder = _configService.SortingSeasonFolderFormat
|
var seasonFolder = _configService.SortingSeasonFolderFormat
|
||||||
.Replace("%0s", seasonNumber.ToString("00"))
|
.Replace("%0s", seasonNumber.ToString("00"))
|
||||||
.Replace("%s", seasonNumber.ToString());
|
.Replace("%s", seasonNumber.ToString());
|
||||||
|
|
||||||
path = Path.Combine(path, seasonFolder);
|
path = Path.Combine(path, seasonFolder);
|
||||||
}
|
}
|
||||||
@ -100,123 +101,5 @@ public FileInfo CalculateFilePath(Series series, int seasonNumber, string fileNa
|
|||||||
|
|
||||||
return new FileInfo(path);
|
return new FileInfo(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string GetNewFilename(IList<Episode> episodes, Series series, Quality quality, bool proper, EpisodeFile episodeFile)
|
|
||||||
{
|
|
||||||
if (_configService.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(_configService.SortingSeparatorStyle);
|
|
||||||
var numberStyle = EpisodeSortingHelper.GetNumberStyle(_configService.SortingNumberStyle);
|
|
||||||
|
|
||||||
var episodeNames = new List<String>();
|
|
||||||
|
|
||||||
episodeNames.Add(Parser.CleanupEpisodeTitle(sortedEpisodes.First().Title));
|
|
||||||
|
|
||||||
string result = String.Empty;
|
|
||||||
|
|
||||||
if (_configService.SortingIncludeSeriesName)
|
|
||||||
{
|
|
||||||
result += series.Title + separatorStyle.Pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (series.SeriesTypes == SeriesTypes.Standard)
|
|
||||||
{
|
|
||||||
result += numberStyle.Pattern.Replace("%0e",
|
|
||||||
String.Format("{0:00}", sortedEpisodes.First().EpisodeNumber));
|
|
||||||
|
|
||||||
if (episodes.Count > 1)
|
|
||||||
{
|
|
||||||
var multiEpisodeStyle =
|
|
||||||
EpisodeSortingHelper.GetMultiEpisodeStyle(_configService.SortingMultiEpisodeStyle);
|
|
||||||
|
|
||||||
foreach (var episode in sortedEpisodes.Skip(1))
|
|
||||||
{
|
|
||||||
if (multiEpisodeStyle.Name == "Duplicate")
|
|
||||||
{
|
|
||||||
result += separatorStyle.Pattern + numberStyle.Pattern;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result += multiEpisodeStyle.Pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = result.Replace("%0e", String.Format("{0:00}", episode.EpisodeNumber));
|
|
||||||
episodeNames.Add(Parser.CleanupEpisodeTitle(episode.Title));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = result
|
|
||||||
.Replace("%s", String.Format("{0}", episodes.First().SeasonNumber))
|
|
||||||
.Replace("%0s", String.Format("{0:00}", episodes.First().SeasonNumber))
|
|
||||||
.Replace("%x", numberStyle.EpisodeSeparator)
|
|
||||||
.Replace("%p", separatorStyle.Pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (episodes.First().AirDate.HasValue)
|
|
||||||
result += episodes.First().AirDate.Value.ToString("yyyy-MM-dd");
|
|
||||||
|
|
||||||
else
|
|
||||||
result += "Unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_configService.SortingIncludeEpisodeTitle)
|
|
||||||
{
|
|
||||||
if (episodeNames.Distinct().Count() == 1)
|
|
||||||
result += separatorStyle.Pattern + episodeNames.First();
|
|
||||||
|
|
||||||
else
|
|
||||||
result += separatorStyle.Pattern + String.Join(" + ", episodeNames.Distinct());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_configService.SortingAppendQuality)
|
|
||||||
{
|
|
||||||
result += String.Format(" [{0}]", quality);
|
|
||||||
|
|
||||||
if (proper)
|
|
||||||
result += " [Proper]";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_configService.SortingReplaceSpaces)
|
|
||||||
result = result.Replace(' ', '.');
|
|
||||||
|
|
||||||
_logger.Trace("New File Name is: [{0}]", result.Trim());
|
|
||||||
return CleanFilename(result.Trim());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static string CleanFilename(string name)
|
|
||||||
{
|
|
||||||
string result = name;
|
|
||||||
string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" };
|
|
||||||
string[] goodCharacters = { "+", "+", "{", "}", "!", "@", "-", "#", "`" };
|
|
||||||
|
|
||||||
for (int i = 0; i < badCharacters.Length; i++)
|
|
||||||
result = result.Replace(badCharacters[i], goodCharacters[i]);
|
|
||||||
|
|
||||||
return result.Trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleAsync(SeriesDeletedEvent message)
|
|
||||||
{
|
|
||||||
var files = GetFilesBySeries(message.Series.Id);
|
|
||||||
_mediaFileRepository.DeleteMany(files);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
@ -77,7 +78,7 @@ public override string ToString()
|
|||||||
|
|
||||||
public string GetDownloadTitle()
|
public string GetDownloadTitle()
|
||||||
{
|
{
|
||||||
var seriesTitle = MediaFileService.CleanFilename(Series.Title);
|
var seriesTitle = FileNameBuilder.CleanFilename(Series.Title);
|
||||||
|
|
||||||
//Handle Full Naming
|
//Handle Full Naming
|
||||||
if (FullSeason)
|
if (FullSeason)
|
||||||
|
@ -234,6 +234,7 @@
|
|||||||
<Compile Include="Lifecycle\IInitializable.cs" />
|
<Compile Include="Lifecycle\IInitializable.cs" />
|
||||||
<Compile Include="MediaCover\MediaCover.cs" />
|
<Compile Include="MediaCover\MediaCover.cs" />
|
||||||
<Compile Include="MediaFiles\MediaFileRepository.cs" />
|
<Compile Include="MediaFiles\MediaFileRepository.cs" />
|
||||||
|
<Compile Include="Organizer\FileNameBuilder.cs" />
|
||||||
<Compile Include="Model\DownloadClientType.cs" />
|
<Compile Include="Model\DownloadClientType.cs" />
|
||||||
<Compile Include="Instrumentation\LogService.cs" />
|
<Compile Include="Instrumentation\LogService.cs" />
|
||||||
<Compile Include="Instrumentation\DatabaseTarget.cs" />
|
<Compile Include="Instrumentation\DatabaseTarget.cs" />
|
||||||
|
207
NzbDrone.Core/Organizer/FileNameBuilder.cs
Normal file
207
NzbDrone.Core/Organizer/FileNameBuilder.cs
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using NLog;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.Helpers;
|
||||||
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Organizer
|
||||||
|
{
|
||||||
|
|
||||||
|
public class NameSpecification : ModelBase
|
||||||
|
{
|
||||||
|
public static NameSpecification Default
|
||||||
|
{
|
||||||
|
get { return new NameSpecification(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SortingUseSceneName { get; set; }
|
||||||
|
|
||||||
|
public int SortingSeparatorStyle { get; set; }
|
||||||
|
|
||||||
|
public int SortingNumberStyle { get; set; }
|
||||||
|
|
||||||
|
public bool SortingIncludeSeriesName { get; set; }
|
||||||
|
|
||||||
|
public int SortingMultiEpisodeStyle { get; set; }
|
||||||
|
|
||||||
|
public bool SortingIncludeEpisodeTitle { get; set; }
|
||||||
|
|
||||||
|
public bool SortingAppendQuality { get; set; }
|
||||||
|
|
||||||
|
public bool SortingReplaceSpaces { get; set; }
|
||||||
|
|
||||||
|
public string SortingSeasonFolderFormat { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public interface IBuildFileNames
|
||||||
|
{
|
||||||
|
string GetNewFilename(IList<Episode> episodes, Series series, Quality quality, bool proper, EpisodeFile episodeFile);
|
||||||
|
FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extension);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FileNameBuilder : IBuildFileNames
|
||||||
|
{
|
||||||
|
private readonly IBasicRepository<NameSpecification> _nameSpecificationRepository;
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
|
public FileNameBuilder(IBasicRepository<NameSpecification> nameSpecificationRepository, Logger logger)
|
||||||
|
{
|
||||||
|
_nameSpecificationRepository = nameSpecificationRepository;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public NameSpecification GetSpecification()
|
||||||
|
{
|
||||||
|
var spec = _nameSpecificationRepository.SingleOrDefault();
|
||||||
|
|
||||||
|
if (spec == null)
|
||||||
|
{
|
||||||
|
spec = NameSpecification.Default;
|
||||||
|
}
|
||||||
|
|
||||||
|
return spec;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetNewFilename(IList<Episode> episodes, Series series, Quality quality, bool proper, EpisodeFile episodeFile)
|
||||||
|
{
|
||||||
|
var nameSpec = GetSpecification();
|
||||||
|
|
||||||
|
|
||||||
|
if (nameSpec.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(nameSpec.SortingSeparatorStyle);
|
||||||
|
var numberStyle = EpisodeSortingHelper.GetNumberStyle(nameSpec.SortingNumberStyle);
|
||||||
|
|
||||||
|
var episodeNames = new List<string>();
|
||||||
|
|
||||||
|
episodeNames.Add(Parser.CleanupEpisodeTitle(sortedEpisodes.First().Title));
|
||||||
|
|
||||||
|
string result = String.Empty;
|
||||||
|
|
||||||
|
if (nameSpec.SortingIncludeSeriesName)
|
||||||
|
{
|
||||||
|
result += series.Title + separatorStyle.Pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (series.SeriesTypes == SeriesTypes.Standard)
|
||||||
|
{
|
||||||
|
result += numberStyle.Pattern.Replace("%0e",
|
||||||
|
String.Format("{0:00}", sortedEpisodes.First().EpisodeNumber));
|
||||||
|
|
||||||
|
if (episodes.Count > 1)
|
||||||
|
{
|
||||||
|
var multiEpisodeStyle =
|
||||||
|
EpisodeSortingHelper.GetMultiEpisodeStyle(nameSpec.SortingMultiEpisodeStyle);
|
||||||
|
|
||||||
|
foreach (var episode in sortedEpisodes.Skip(1))
|
||||||
|
{
|
||||||
|
if (multiEpisodeStyle.Name == "Duplicate")
|
||||||
|
{
|
||||||
|
result += separatorStyle.Pattern + numberStyle.Pattern;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += multiEpisodeStyle.Pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = result.Replace("%0e", String.Format("{0:00}", episode.EpisodeNumber));
|
||||||
|
episodeNames.Add(Parser.CleanupEpisodeTitle(episode.Title));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result = result
|
||||||
|
.Replace("%s", String.Format("{0}", episodes.First().SeasonNumber))
|
||||||
|
.Replace("%0s", String.Format("{0:00}", episodes.First().SeasonNumber))
|
||||||
|
.Replace("%x", numberStyle.EpisodeSeparator)
|
||||||
|
.Replace("%p", separatorStyle.Pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (episodes.First().AirDate.HasValue)
|
||||||
|
result += episodes.First().AirDate.Value.ToString("yyyy-MM-dd");
|
||||||
|
|
||||||
|
else
|
||||||
|
result += "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nameSpec.SortingIncludeEpisodeTitle)
|
||||||
|
{
|
||||||
|
if (episodeNames.Distinct().Count() == 1)
|
||||||
|
result += separatorStyle.Pattern + episodeNames.First();
|
||||||
|
|
||||||
|
else
|
||||||
|
result += separatorStyle.Pattern + String.Join(" + ", episodeNames.Distinct());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nameSpec.SortingAppendQuality)
|
||||||
|
{
|
||||||
|
result += String.Format(" [{0}]", quality);
|
||||||
|
|
||||||
|
if (proper)
|
||||||
|
result += " [Proper]";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nameSpec.SortingReplaceSpaces)
|
||||||
|
result = result.Replace(' ', '.');
|
||||||
|
|
||||||
|
_logger.Trace("New File Name is: [{0}]", result.Trim());
|
||||||
|
return CleanFilename(result.Trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extension)
|
||||||
|
{
|
||||||
|
|
||||||
|
var nameSpec = GetSpecification();
|
||||||
|
|
||||||
|
string path = series.Path;
|
||||||
|
if (series.SeasonFolder)
|
||||||
|
{
|
||||||
|
var seasonFolder = nameSpec.SortingSeasonFolderFormat
|
||||||
|
.Replace("%0s", seasonNumber.ToString("00"))
|
||||||
|
.Replace("%s", seasonNumber.ToString());
|
||||||
|
|
||||||
|
path = Path.Combine(path, seasonFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
path = Path.Combine(path, fileName + extension);
|
||||||
|
|
||||||
|
return new FileInfo(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static string CleanFilename(string name)
|
||||||
|
{
|
||||||
|
string result = name;
|
||||||
|
string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" };
|
||||||
|
string[] goodCharacters = { "+", "+", "{", "}", "!", "@", "-", "#", "`" };
|
||||||
|
|
||||||
|
for (int i = 0; i < badCharacters.Length; i++)
|
||||||
|
result = result.Replace(badCharacters[i], goodCharacters[i]);
|
||||||
|
|
||||||
|
return result.Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,8 +7,8 @@
|
|||||||
using NzbDrone.Common.Eventing;
|
using NzbDrone.Common.Eventing;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.ExternalNotification;
|
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
|
|
||||||
@ -17,23 +17,25 @@ namespace NzbDrone.Core.Providers
|
|||||||
public class DiskScanProvider
|
public class DiskScanProvider
|
||||||
{
|
{
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
private static readonly string[] mediaExtentions = new[] { ".mkv", ".avi", ".wmv", ".mp4", ".mpg", ".mpeg", ".xvid", ".flv", ".mov", ".rm", ".rmvb", ".divx", ".dvr-ms", ".ts", ".ogm", ".m4v", ".strm" };
|
private static readonly string[] MediaExtensions = new[] { ".mkv", ".avi", ".wmv", ".mp4", ".mpg", ".mpeg", ".xvid", ".flv", ".mov", ".rm", ".rmvb", ".divx", ".dvr-ms", ".ts", ".ogm", ".m4v", ".strm" };
|
||||||
private readonly DiskProvider _diskProvider;
|
private readonly DiskProvider _diskProvider;
|
||||||
private readonly IEpisodeService _episodeService;
|
private readonly IEpisodeService _episodeService;
|
||||||
private readonly IMediaFileService _mediaFileService;
|
private readonly IMediaFileService _mediaFileService;
|
||||||
private readonly IConfigService _configService;
|
private readonly IConfigService _configService;
|
||||||
|
private readonly IBuildFileNames _buildFileNames;
|
||||||
private readonly RecycleBinProvider _recycleBinProvider;
|
private readonly RecycleBinProvider _recycleBinProvider;
|
||||||
private readonly MediaInfoProvider _mediaInfoProvider;
|
private readonly MediaInfoProvider _mediaInfoProvider;
|
||||||
private readonly ISeriesRepository _seriesRepository;
|
private readonly ISeriesRepository _seriesRepository;
|
||||||
private readonly IEventAggregator _eventAggregator;
|
private readonly IEventAggregator _eventAggregator;
|
||||||
|
|
||||||
public DiskScanProvider(DiskProvider diskProvider, IEpisodeService episodeService, IMediaFileService mediaFileService, IConfigService configService,
|
public DiskScanProvider(DiskProvider diskProvider, IEpisodeService episodeService, IMediaFileService mediaFileService, IConfigService configService,IBuildFileNames buildFileNames,
|
||||||
RecycleBinProvider recycleBinProvider, MediaInfoProvider mediaInfoProvider, ISeriesRepository seriesRepository, IEventAggregator eventAggregator)
|
RecycleBinProvider recycleBinProvider, MediaInfoProvider mediaInfoProvider, ISeriesRepository seriesRepository, IEventAggregator eventAggregator)
|
||||||
{
|
{
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_episodeService = episodeService;
|
_episodeService = episodeService;
|
||||||
_mediaFileService = mediaFileService;
|
_mediaFileService = mediaFileService;
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
|
_buildFileNames = buildFileNames;
|
||||||
_recycleBinProvider = recycleBinProvider;
|
_recycleBinProvider = recycleBinProvider;
|
||||||
_mediaInfoProvider = mediaInfoProvider;
|
_mediaInfoProvider = mediaInfoProvider;
|
||||||
_seriesRepository = seriesRepository;
|
_seriesRepository = seriesRepository;
|
||||||
@ -186,8 +188,8 @@ public virtual EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, bool newDown
|
|||||||
|
|
||||||
var series = _seriesRepository.Get(episodeFile.SeriesId);
|
var series = _seriesRepository.Get(episodeFile.SeriesId);
|
||||||
var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id);
|
var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id);
|
||||||
string newFileName = _mediaFileService.GetNewFilename(episodes, series, episodeFile.Quality, episodeFile.Proper, episodeFile);
|
string newFileName = _buildFileNames.GetNewFilename(episodes, series, episodeFile.Quality, episodeFile.Proper, episodeFile);
|
||||||
var newFile = _mediaFileService.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
var newFile = _buildFileNames.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
||||||
|
|
||||||
//Only rename if existing and new filenames don't match
|
//Only rename if existing and new filenames don't match
|
||||||
if (DiskProvider.PathEquals(episodeFile.Path, newFile.FullName))
|
if (DiskProvider.PathEquals(episodeFile.Path, newFile.FullName))
|
||||||
@ -308,7 +310,7 @@ public virtual List<string> GetVideoFiles(string path, bool allDirectories = tru
|
|||||||
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||||
var filesOnDisk = _diskProvider.GetFiles(path, searchOption);
|
var filesOnDisk = _diskProvider.GetFiles(path, searchOption);
|
||||||
|
|
||||||
var mediaFileList = filesOnDisk.Where(c => mediaExtentions.Contains(Path.GetExtension(c).ToLower())).ToList();
|
var mediaFileList = filesOnDisk.Where(c => MediaExtensions.Contains(Path.GetExtension(c).ToLower())).ToList();
|
||||||
|
|
||||||
Logger.Trace("{0} video files were found in {1}", mediaFileList.Count, path);
|
Logger.Trace("{0} video files were found in {1}", mediaFileList.Count, path);
|
||||||
return mediaFileList;
|
return mediaFileList;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
@ -14,15 +14,15 @@ namespace NzbDrone.Core.Providers
|
|||||||
{
|
{
|
||||||
public class MisnamedProvider
|
public class MisnamedProvider
|
||||||
{
|
{
|
||||||
private readonly IMediaFileService _mediaFileService;
|
|
||||||
private readonly IEpisodeService _episodeService;
|
private readonly IEpisodeService _episodeService;
|
||||||
|
private readonly IBuildFileNames _buildFileNames;
|
||||||
|
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public MisnamedProvider(IMediaFileService mediaFileService, IEpisodeService episodeService)
|
public MisnamedProvider(IEpisodeService episodeService, IBuildFileNames buildFileNames)
|
||||||
{
|
{
|
||||||
_mediaFileService = mediaFileService;
|
|
||||||
_episodeService = episodeService;
|
_episodeService = episodeService;
|
||||||
|
_buildFileNames = buildFileNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual List<MisnamedEpisodeModel> MisnamedFiles(int pageNumber, int pageSize, out int totalItems)
|
public virtual List<MisnamedEpisodeModel> MisnamedFiles(int pageNumber, int pageSize, out int totalItems)
|
||||||
@ -37,7 +37,7 @@ public virtual List<MisnamedEpisodeModel> MisnamedFiles(int pageNumber, int page
|
|||||||
var misnamedFilesSelect = episodesWithFiles.AsParallel().Where(
|
var misnamedFilesSelect = episodesWithFiles.AsParallel().Where(
|
||||||
w =>
|
w =>
|
||||||
w.First().EpisodeFile.Path !=
|
w.First().EpisodeFile.Path !=
|
||||||
_mediaFileService.GetNewFilename(w.Select(e => e).ToList(), w.First().Series,
|
_buildFileNames.GetNewFilename(w.Select(e => e).ToList(), w.First().Series,
|
||||||
w.First().EpisodeFile.Quality, w.First().EpisodeFile.Proper, w.First().EpisodeFile)).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
|
//Process the episodes
|
||||||
@ -45,7 +45,7 @@ public virtual List<MisnamedEpisodeModel> MisnamedFiles(int pageNumber, int page
|
|||||||
{
|
{
|
||||||
var episodes = f.Select(e => e).ToList();
|
var episodes = f.Select(e => e).ToList();
|
||||||
var firstEpisode = episodes[0];
|
var firstEpisode = episodes[0];
|
||||||
var properName = _mediaFileService.GetNewFilename(episodes,
|
var properName = _buildFileNames.GetNewFilename(episodes,
|
||||||
firstEpisode.Series,
|
firstEpisode.Series,
|
||||||
firstEpisode.EpisodeFile.Quality, firstEpisode.EpisodeFile.Proper, firstEpisode.EpisodeFile);
|
firstEpisode.EpisodeFile.Quality, firstEpisode.EpisodeFile.Proper, firstEpisode.EpisodeFile);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user