moved naming specification out of general config.
This commit is contained in:
parent
db37d020f4
commit
dce64a5530
|
@ -14,6 +14,7 @@
|
|||
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
|
||||
<DefaultTestTimeout>60000</DefaultTestTimeout>
|
||||
<UseBuildConfiguration></UseBuildConfiguration>
|
||||
<UseBuildPlatform />
|
||||
<ProxyProcessPath></ProxyProcessPath>
|
||||
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
|
||||
<IgnoredTests>
|
||||
|
@ -32,5 +33,8 @@
|
|||
<NamedTestSelector>
|
||||
<TestName>NzbDrone.Common.Test.ServiceProviderTests.Should_be_able_to_start_and_stop_service</TestName>
|
||||
</NamedTestSelector>
|
||||
<RegexTestSelector>
|
||||
<RegularExpression>.*</RegularExpression>
|
||||
</RegexTestSelector>
|
||||
</IgnoredTests>
|
||||
</ProjectConfiguration>
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -174,7 +174,7 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(p => p.GetFilesBySeries(seriesId))
|
||||
.Returns(episodesFiles);
|
||||
.Returns(episodesFiles.ToList());
|
||||
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Setup(p => p.GetSeasonNumbers(seriesId))
|
||||
|
@ -200,7 +200,7 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(p => p.GetFilesBySeries(seriesId))
|
||||
.Returns(episodesFiles);
|
||||
.Returns(episodesFiles.ToList());
|
||||
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Setup(p => p.GetSeasonNumbers(seriesId))
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(s => s.GetFilesBySeason(_series.Id, 5))
|
||||
.Returns(_episodeFiles);
|
||||
.Returns(_episodeFiles.ToList());
|
||||
}
|
||||
|
||||
private void WithMovedFiles()
|
||||
|
|
|
@ -4,6 +4,7 @@ using FluentAssertions;
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
|
@ -17,7 +18,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
[TestCase("Law & Order: Criminal Intent - S10E07 - Icarus [HDTV-720p]", "Law & Order- Criminal Intent - S10E07 - Icarus [HDTV-720p]")]
|
||||
public void CleanFileName(string name, string expectedName)
|
||||
{
|
||||
MediaFileService.CleanFilename(name).Should().Be(expectedName);
|
||||
FileNameBuilder.CleanFilename(name).Should().Be(expectedName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -222,7 +222,7 @@
|
|||
<Compile Include="ProviderTests\DiskScanProviderTests\ImportFileFixture.cs" />
|
||||
<Compile Include="FluentTest.cs" />
|
||||
<Compile Include="InstrumentationTests\DatabaseTargetFixture.cs" />
|
||||
<Compile Include="MediaFileTests\GetNewFilenameFixture.cs" />
|
||||
<Compile Include="OrganizerTests\GetNewFilenameFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\MonitoredEpisodeSpecificationFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadProviderTests\DownloadProviderFixture.cs" />
|
||||
<Compile Include="EpisodeStatusTest.cs" />
|
||||
|
|
|
@ -1,26 +1,28 @@
|
|||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFileTests
|
||||
namespace NzbDrone.Core.Test.OrganizerTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class MediaFileProvider_GetNewFilenameTest : CoreTest
|
||||
public class MediaFileProvider_GetNewFilenameTest : CoreTest<FileNameBuilder>
|
||||
{
|
||||
private Series _series;
|
||||
|
||||
private NameSpecification nameSpecification;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
|
@ -28,6 +30,15 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.CreateNew()
|
||||
.With(s => s.Title = "South Park")
|
||||
.Build();
|
||||
|
||||
|
||||
nameSpecification = new NameSpecification();
|
||||
|
||||
|
||||
Mocker.GetMock<IBasicRepository<NameSpecification>>()
|
||||
.Setup(c => c.SingleOrDefault()).Returns(nameSpecification);
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -36,13 +47,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
|
@ -51,7 +62,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("South Park - S15E06 - City Sushi [HDTV-720p]", result);
|
||||
|
@ -63,13 +74,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = false;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 0;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
|
@ -78,7 +89,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("15x06 - City Sushi [HDTV-720p]", result);
|
||||
|
@ -90,13 +101,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(1);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(1);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = false;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 1;
|
||||
nameSpecification.SortingNumberStyle = 1;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
|
@ -105,7 +116,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("South Park 05x06 [HDTV-720p]", result);
|
||||
|
@ -117,13 +128,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(1);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(3);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = false;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 1;
|
||||
nameSpecification.SortingNumberStyle = 3;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
|
@ -133,7 +144,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("South Park s05e06", result);
|
||||
|
@ -145,13 +156,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(1);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(3);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(true);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 1;
|
||||
nameSpecification.SortingNumberStyle = 3;
|
||||
nameSpecification.SortingReplaceSpaces = true;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
|
@ -160,7 +171,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("South.Park.s05e06.City.Sushi", result);
|
||||
|
@ -172,13 +183,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(3);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(true);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 3;
|
||||
nameSpecification.SortingReplaceSpaces = true;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
|
@ -187,7 +198,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("South.Park.-.s05e06.-.City.Sushi.[HDTV-720p]", result);
|
||||
|
@ -199,13 +210,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = false;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = false;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
|
@ -215,7 +226,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("S15E06", result);
|
||||
|
@ -227,14 +238,14 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
nameSpecification.SortingMultiEpisodeStyle = 3;
|
||||
|
||||
var episodeOne = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "Strawberries and Cream (1)")
|
||||
|
@ -249,7 +260,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("The Mentalist - S03E23-E24 - Strawberries and Cream [HDTV-720p]", result);
|
||||
|
@ -261,14 +272,14 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(2);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = false;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 0;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
nameSpecification.SortingMultiEpisodeStyle = 2;
|
||||
|
||||
var episodeOne = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "Strawberries and Cream (1)")
|
||||
|
@ -283,7 +294,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("3x23x24 - Strawberries and Cream [HDTV-720p]", result);
|
||||
|
@ -295,14 +306,14 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(1);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(2);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = false;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 1;
|
||||
nameSpecification.SortingNumberStyle = 0;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
nameSpecification.SortingMultiEpisodeStyle = 2;
|
||||
|
||||
var episodeOne = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "Strawberries and Cream (1)")
|
||||
|
@ -317,7 +328,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("3x23x24 Strawberries and Cream [HDTV-720p]", result);
|
||||
|
@ -329,14 +340,14 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(1);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(3);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(1);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 1;
|
||||
nameSpecification.SortingNumberStyle = 3;
|
||||
nameSpecification.SortingReplaceSpaces = true;
|
||||
nameSpecification.SortingMultiEpisodeStyle = 1;
|
||||
|
||||
var episodeOne = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "Strawberries and Cream (1)")
|
||||
|
@ -351,7 +362,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("The.Mentalist.s03e23.s03e24.Strawberries.and.Cream", result);
|
||||
|
@ -363,14 +374,14 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(0);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = false;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = true;
|
||||
nameSpecification.SortingMultiEpisodeStyle = 0;
|
||||
|
||||
var episodeOne = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "Strawberries and Cream (1)")
|
||||
|
@ -385,7 +396,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("The.Mentalist.-.S03E23-24", result);
|
||||
|
@ -397,14 +408,14 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(2);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = false;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = false;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 0;
|
||||
nameSpecification.SortingReplaceSpaces = true;
|
||||
nameSpecification.SortingMultiEpisodeStyle = 2;
|
||||
|
||||
var episodeOne = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "Strawberries and Cream (1)")
|
||||
|
@ -419,7 +430,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("3x23x24", result);
|
||||
|
@ -429,13 +440,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
public void GetNewFilename_should_append_proper_when_proper_and_append_quality_is_true()
|
||||
{
|
||||
//Setup
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
|
@ -444,7 +455,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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
|
||||
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p] [Proper]");
|
||||
|
@ -454,13 +465,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
public void GetNewFilename_should_not_append_proper_when_not_proper_and_append_quality_is_true()
|
||||
{
|
||||
//Setup
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
|
@ -469,7 +480,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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
|
||||
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p]");
|
||||
|
@ -479,13 +490,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
public void GetNewFilename_should_not_append_proper_when_proper_and_append_quality_is_false()
|
||||
{
|
||||
//Setup
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
|
@ -494,7 +505,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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
|
||||
result.Should().Be("South Park - S15E06 - City Sushi");
|
||||
|
@ -504,14 +515,14 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
public void GetNewFilename_should_order_multiple_episode_files_in_numerical_order()
|
||||
{
|
||||
//Setup
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
nameSpecification.SortingMultiEpisodeStyle = 3;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "Hey, Baby, What's Wrong? (1)")
|
||||
|
@ -526,7 +537,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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
|
||||
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
|
||||
|
@ -538,13 +549,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 2;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
|
@ -553,7 +564,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("South Park.S15E06.City Sushi [HDTV-720p]", result);
|
||||
|
@ -565,13 +576,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
//Setup
|
||||
|
||||
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = false;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 2;
|
||||
nameSpecification.SortingNumberStyle = 0;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
|
@ -580,7 +591,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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.AreEqual("15x06.City Sushi [HDTV-720p]", result);
|
||||
|
@ -590,14 +601,14 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
public void GetNewFilename_UseSceneName_when_sceneName_isNull()
|
||||
{
|
||||
//Setup
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingUseSceneName).Returns(true);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = false;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 2;
|
||||
nameSpecification.SortingNumberStyle = 0;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
nameSpecification.SortingUseSceneName = true;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
|
@ -611,7 +622,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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
|
||||
result.Should().Be(Path.GetFileNameWithoutExtension(episodeFile.Path));
|
||||
|
@ -621,14 +632,14 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
public void GetNewFilename_UseSceneName_when_sceneName_isNotNull()
|
||||
{
|
||||
//Setup
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingUseSceneName).Returns(true);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = false;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 2;
|
||||
nameSpecification.SortingNumberStyle = 0;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
nameSpecification.SortingUseSceneName = true;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
|
@ -642,7 +653,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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
|
||||
result.Should().Be(episodeFile.SceneName);
|
||||
|
@ -652,14 +663,14 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
public void should_only_have_one_episodeTitle_when_episode_titles_are_the_same()
|
||||
{
|
||||
//Setup
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
nameSpecification.SortingMultiEpisodeStyle = 3;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "Hey, Baby, What's Wrong? (1)")
|
||||
|
@ -674,7 +685,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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
|
||||
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
|
||||
|
@ -684,14 +695,14 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
public void should_have_two_episodeTitles_when_episode_titles_are_not_the_same()
|
||||
{
|
||||
//Setup
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
nameSpecification.SortingMultiEpisodeStyle = 3;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "Hello")
|
||||
|
@ -706,7 +717,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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
|
||||
result.Should().Be("30 Rock - S06E06-E07 - Hello + World");
|
||||
|
@ -716,14 +727,14 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
public void should_have_two_episodeTitles_when_distinct_count_is_two()
|
||||
{
|
||||
//Setup
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
nameSpecification.SortingMultiEpisodeStyle = 3;
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "Hello (3)")
|
||||
|
@ -744,7 +755,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.Build();
|
||||
|
||||
//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
|
||||
result.Should().Be("30 Rock - S06E06-E07-E08 - Hello + World");
|
||||
|
@ -753,13 +764,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
[Test]
|
||||
public void should_use_airDate_if_series_isDaily()
|
||||
{
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = true;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
var series = Builder<Series>
|
||||
.CreateNew()
|
||||
|
@ -774,7 +785,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.With(e => e.Title = "Kristen Stewart")
|
||||
.Build();
|
||||
|
||||
var result = Mocker.Resolve<IMediaFileService>()
|
||||
var result = Subject
|
||||
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
|
||||
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13 - Kristen Stewart [HDTV-720p]");
|
||||
}
|
||||
|
@ -782,13 +793,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
[Test]
|
||||
public void should_use_airDate_if_series_isDaily_no_episode_title()
|
||||
{
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = false;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
var series = Builder<Series>
|
||||
.CreateNew()
|
||||
|
@ -803,7 +814,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.With(e => e.Title = "Kristen Stewart")
|
||||
.Build();
|
||||
|
||||
var result = Mocker.Resolve<IMediaFileService>()
|
||||
var result = Subject
|
||||
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
|
||||
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13");
|
||||
}
|
||||
|
@ -811,13 +822,13 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
[Test]
|
||||
public void should_set_airdate_to_unknown_if_not_available()
|
||||
{
|
||||
var fakeConfig = Mocker.GetMock<IConfigService>();
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||
|
||||
nameSpecification.SortingIncludeSeriesName = true;
|
||||
nameSpecification.SortingIncludeEpisodeTitle = true;
|
||||
nameSpecification.SortingAppendQuality = false;
|
||||
nameSpecification.SortingSeparatorStyle = 0;
|
||||
nameSpecification.SortingNumberStyle = 2;
|
||||
nameSpecification.SortingReplaceSpaces = false;
|
||||
|
||||
var series = Builder<Series>
|
||||
.CreateNew()
|
||||
|
@ -832,7 +843,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
|||
.With(e => e.Title = "Kristen Stewart")
|
||||
.Build();
|
||||
|
||||
var result = Mocker.Resolve<IMediaFileService>()
|
||||
var result = Subject
|
||||
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
|
||||
result.Should().Be("The Daily Show with Jon Stewart - Unknown - Kristen Stewart");
|
||||
}
|
|
@ -9,6 +9,7 @@ using Moq;
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
|
@ -106,10 +107,10 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
Mocker.GetMock<IEpisodeService>().Setup(s => s.GetEpisodesByFileId(episodeFile.Id))
|
||||
.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);
|
||||
|
||||
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));
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
|
|
|
@ -11,6 +11,7 @@ using NzbDrone.Common;
|
|||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.ExternalNotification;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
|
@ -56,11 +57,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
.Setup(e => e.GetEpisodesByFileId(file.Id))
|
||||
.Returns(fakeEpisode);
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
|
||||
.Returns(filename);
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".avi"))
|
||||
.Returns(fi);
|
||||
|
||||
|
@ -106,11 +107,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
.Setup(e => e.GetEpisodesByFileId(file.Id))
|
||||
.Returns(fakeEpisode);
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
|
||||
.Returns(filename);
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
|
||||
.Returns(fi);
|
||||
|
||||
|
@ -158,11 +159,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
.Setup(e => e.GetEpisodesByFileId(file.Id))
|
||||
.Returns(fakeEpisode);
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
|
||||
.Returns(filename);
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
|
||||
.Returns(fi);
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ using FluentAssertions;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
@ -48,11 +49,11 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
Mocker.GetMock<IEpisodeService>()
|
||||
.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]))
|
||||
.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]))
|
||||
.Returns("Title2");
|
||||
|
||||
|
@ -95,11 +96,11 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
Mocker.GetMock<IEpisodeService>()
|
||||
.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]))
|
||||
.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]))
|
||||
.Returns("New Title 2");
|
||||
|
||||
|
@ -142,11 +143,11 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
Mocker.GetMock<IEpisodeService>()
|
||||
.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]))
|
||||
.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]))
|
||||
.Returns("Title2");
|
||||
|
||||
|
@ -191,11 +192,11 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
Mocker.GetMock<IEpisodeService>()
|
||||
.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]))
|
||||
.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]))
|
||||
.Returns("Title2");
|
||||
|
||||
|
@ -240,11 +241,11 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
Mocker.GetMock<IEpisodeService>()
|
||||
.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]))
|
||||
.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]))
|
||||
.Returns("Title2");
|
||||
|
||||
|
|
|
@ -149,29 +149,6 @@ namespace NzbDrone.Core.Configuration
|
|||
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
|
||||
{
|
||||
|
@ -186,30 +163,6 @@ namespace NzbDrone.Core.Configuration
|
|||
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
|
||||
{
|
||||
get { return GetValueInt("DefaultQualityProfile", 1); }
|
||||
|
|
|
@ -25,16 +25,8 @@ namespace NzbDrone.Core.Configuration
|
|||
SabPriorityType SabBacklogTvPriority { get; set; }
|
||||
SabPriorityType SabRecentTvPriority { 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; }
|
||||
string SortingSeasonFolderFormat { get; set; }
|
||||
int SortingSeparatorStyle { get; set; }
|
||||
int SortingNumberStyle { get; set; }
|
||||
int SortingMultiEpisodeStyle { get; set; }
|
||||
bool SortingUseSceneName { get; set; }
|
||||
int DefaultQualityProfile { get; set; }
|
||||
Boolean XbmcUpdateLibrary { get; set; }
|
||||
Boolean XbmcCleanLibrary { get; set; }
|
||||
|
|
|
@ -8,13 +8,15 @@ namespace NzbDrone.Core.Datastore
|
|||
IEnumerable<TModel> All();
|
||||
int Count();
|
||||
TModel Get(int id);
|
||||
TModel Single();
|
||||
TModel SingleOrDefault();
|
||||
TModel Insert(TModel model);
|
||||
TModel Update(TModel model);
|
||||
TModel Upsert(TModel model);
|
||||
TModel UpSert(TModel model);
|
||||
void Delete(int id);
|
||||
IList<TModel> InsertMany(IList<TModel> model);
|
||||
IList<TModel> UpdateMany(IList<TModel> model);
|
||||
void DeleteMany(IList<TModel> model);
|
||||
void DeleteMany(List<TModel> model);
|
||||
void Purge();
|
||||
bool HasItems();
|
||||
}
|
||||
|
@ -45,6 +47,16 @@ namespace NzbDrone.Core.Datastore
|
|||
return Queryable.Single(c => c.Id == id);
|
||||
}
|
||||
|
||||
public TModel Single()
|
||||
{
|
||||
return Queryable.Single();
|
||||
}
|
||||
|
||||
public TModel SingleOrDefault()
|
||||
{
|
||||
return Queryable.SingleOrDefault();
|
||||
}
|
||||
|
||||
public TModel Insert(TModel model)
|
||||
{
|
||||
return ObjectDatabase.Insert(model);
|
||||
|
@ -65,12 +77,12 @@ namespace NzbDrone.Core.Datastore
|
|||
return ObjectDatabase.UpdateMany(model);
|
||||
}
|
||||
|
||||
public void DeleteMany(IList<TModel> model)
|
||||
public void DeleteMany(List<TModel> model)
|
||||
{
|
||||
ObjectDatabase.DeleteMany(model);
|
||||
}
|
||||
|
||||
public TModel Upsert(TModel model)
|
||||
public TModel UpSert(TModel model)
|
||||
{
|
||||
if (model.Id == 0)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ using NzbDrone.Core.History;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Organizer;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients
|
||||
{
|
||||
|
@ -37,7 +38,7 @@ namespace NzbDrone.Core.Download.Clients
|
|||
{
|
||||
try
|
||||
{
|
||||
title = MediaFileService.CleanFilename(title);
|
||||
title = FileNameBuilder.CleanFilename(title);
|
||||
|
||||
var filename = Path.Combine(_configService.BlackholeDirectory, title + ".nzb");
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ using NzbDrone.Core.Configuration;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Organizer;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients
|
||||
{
|
||||
|
@ -43,7 +44,7 @@ namespace NzbDrone.Core.Download.Clients
|
|||
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)
|
||||
var filename = Path.Combine(_configService.PneumaticDirectory, title + ".nzb");
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace NzbDrone.Core.ExternalNotification
|
|||
new ExternalNotificationDefinition { Name = Name };
|
||||
|
||||
updateAction(def);
|
||||
_externalNotificationRepository.Upsert(def);
|
||||
_externalNotificationRepository.UpSert(def);
|
||||
}
|
||||
|
||||
private bool GetEnableStatus(Func<ExternalNotificationDefinition, bool> readFunction)
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace NzbDrone.Core.Indexers
|
|||
{
|
||||
//Todo: This will be used in the API
|
||||
_logger.Debug("Upserting Indexer definitions for {0}", indexer.Name);
|
||||
_indexerRepository.Upsert(indexer);
|
||||
_indexerRepository.UpSert(indexer);
|
||||
}
|
||||
|
||||
public Indexer GetSettings(Type type)
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace NzbDrone.Core.Jobs
|
|||
|
||||
jobDefinition.Interval = Convert.ToInt32(job.DefaultInterval.TotalMinutes);
|
||||
|
||||
Upsert(jobDefinition);
|
||||
UpSert(jobDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Eventing;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Helpers;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles
|
||||
|
@ -19,10 +15,8 @@ namespace NzbDrone.Core.MediaFiles
|
|||
void Delete(int episodeFileId);
|
||||
bool Exists(string path);
|
||||
EpisodeFile GetFileByPath(string path);
|
||||
IList<EpisodeFile> GetFilesBySeries(int seriesId);
|
||||
IList<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);
|
||||
List<EpisodeFile> GetFilesBySeries(int seriesId);
|
||||
List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber);
|
||||
}
|
||||
|
||||
public class MediaFileService : IMediaFileService, IHandleAsync<SeriesDeletedEvent>
|
||||
|
@ -73,25 +67,32 @@ namespace NzbDrone.Core.MediaFiles
|
|||
return _mediaFileRepository.GetFileByPath(path.Normalize());
|
||||
}
|
||||
|
||||
public IList<EpisodeFile> GetFilesBySeries(int seriesId)
|
||||
public List<EpisodeFile> GetFilesBySeries(int 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
string path = series.Path;
|
||||
if (series.SeasonFolder)
|
||||
{
|
||||
var seasonFolder = _configService.SortingSeasonFolderFormat
|
||||
.Replace("%0s", seasonNumber.ToString("00"))
|
||||
.Replace("%s", seasonNumber.ToString());
|
||||
.Replace("%0s", seasonNumber.ToString("00"))
|
||||
.Replace("%s", seasonNumber.ToString());
|
||||
|
||||
path = Path.Combine(path, seasonFolder);
|
||||
}
|
||||
|
@ -100,123 +101,5 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
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.Collections.Generic;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
@ -77,7 +78,7 @@ namespace NzbDrone.Core.Model
|
|||
|
||||
public string GetDownloadTitle()
|
||||
{
|
||||
var seriesTitle = MediaFileService.CleanFilename(Series.Title);
|
||||
var seriesTitle = FileNameBuilder.CleanFilename(Series.Title);
|
||||
|
||||
//Handle Full Naming
|
||||
if (FullSeason)
|
||||
|
|
|
@ -234,6 +234,7 @@
|
|||
<Compile Include="Lifecycle\IInitializable.cs" />
|
||||
<Compile Include="MediaCover\MediaCover.cs" />
|
||||
<Compile Include="MediaFiles\MediaFileRepository.cs" />
|
||||
<Compile Include="Organizer\FileNameBuilder.cs" />
|
||||
<Compile Include="Model\DownloadClientType.cs" />
|
||||
<Compile Include="Instrumentation\LogService.cs" />
|
||||
<Compile Include="Instrumentation\DatabaseTarget.cs" />
|
||||
|
|
|
@ -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;
|
|||
using NzbDrone.Common.Eventing;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.ExternalNotification;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
|
||||
|
@ -17,23 +17,25 @@ namespace NzbDrone.Core.Providers
|
|||
public class DiskScanProvider
|
||||
{
|
||||
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 IEpisodeService _episodeService;
|
||||
private readonly IMediaFileService _mediaFileService;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly IBuildFileNames _buildFileNames;
|
||||
private readonly RecycleBinProvider _recycleBinProvider;
|
||||
private readonly MediaInfoProvider _mediaInfoProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
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)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
_episodeService = episodeService;
|
||||
_mediaFileService = mediaFileService;
|
||||
_configService = configService;
|
||||
_buildFileNames = buildFileNames;
|
||||
_recycleBinProvider = recycleBinProvider;
|
||||
_mediaInfoProvider = mediaInfoProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
|
@ -186,8 +188,8 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
var series = _seriesRepository.Get(episodeFile.SeriesId);
|
||||
var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id);
|
||||
string newFileName = _mediaFileService.GetNewFilename(episodes, series, episodeFile.Quality, episodeFile.Proper, episodeFile);
|
||||
var newFile = _mediaFileService.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
||||
string newFileName = _buildFileNames.GetNewFilename(episodes, series, episodeFile.Quality, episodeFile.Proper, episodeFile);
|
||||
var newFile = _buildFileNames.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
||||
|
||||
//Only rename if existing and new filenames don't match
|
||||
if (DiskProvider.PathEquals(episodeFile.Path, newFile.FullName))
|
||||
|
@ -308,7 +310,7 @@ namespace NzbDrone.Core.Providers
|
|||
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||
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);
|
||||
return mediaFileList;
|
||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using NLog;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
@ -14,15 +14,15 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
public class MisnamedProvider
|
||||
{
|
||||
private readonly IMediaFileService _mediaFileService;
|
||||
private readonly IEpisodeService _episodeService;
|
||||
private readonly IBuildFileNames _buildFileNames;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public MisnamedProvider(IMediaFileService mediaFileService, IEpisodeService episodeService)
|
||||
public MisnamedProvider(IEpisodeService episodeService, IBuildFileNames buildFileNames)
|
||||
{
|
||||
_mediaFileService = mediaFileService;
|
||||
_episodeService = episodeService;
|
||||
_buildFileNames = buildFileNames;
|
||||
}
|
||||
|
||||
public virtual List<MisnamedEpisodeModel> MisnamedFiles(int pageNumber, int pageSize, out int totalItems)
|
||||
|
@ -37,7 +37,7 @@ namespace NzbDrone.Core.Providers
|
|||
var misnamedFilesSelect = episodesWithFiles.AsParallel().Where(
|
||||
w =>
|
||||
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);
|
||||
|
||||
//Process the episodes
|
||||
|
@ -45,7 +45,7 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
var episodes = f.Select(e => e).ToList();
|
||||
var firstEpisode = episodes[0];
|
||||
var properName = _mediaFileService.GetNewFilename(episodes,
|
||||
var properName = _buildFileNames.GetNewFilename(episodes,
|
||||
firstEpisode.Series,
|
||||
firstEpisode.EpisodeFile.Quality, firstEpisode.EpisodeFile.Proper, firstEpisode.EpisodeFile);
|
||||
|
||||
|
|
Loading…
Reference in New Issue