file name builder cleanup.

pull/6/head
kay.one 12 years ago
parent dce64a5530
commit f21358fce5

@ -48,12 +48,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("South Park - S15E06 - City Sushi [HDTV-720p]", result);
@ -75,12 +75,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = false;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 0;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = false;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("15x06 - City Sushi [HDTV-720p]", result);
@ -102,12 +102,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = false;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 1;
nameSpecification.SortingNumberStyle = 1;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = false;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 1;
nameSpecification.NumberStyle = 1;
nameSpecification.ReplaceSpaces = false;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
@ -116,7 +116,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("South Park 05x06 [HDTV-720p]", result);
@ -129,12 +129,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = false;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 1;
nameSpecification.SortingNumberStyle = 3;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = false;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 1;
nameSpecification.NumberStyle = 3;
nameSpecification.ReplaceSpaces = false;
var episode = Builder<Episode>.CreateNew()
@ -144,7 +144,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("South Park s05e06", result);
@ -157,12 +157,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 1;
nameSpecification.SortingNumberStyle = 3;
nameSpecification.SortingReplaceSpaces = true;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 1;
nameSpecification.NumberStyle = 3;
nameSpecification.ReplaceSpaces = true;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
@ -171,7 +171,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("South.Park.s05e06.City.Sushi", result);
@ -184,12 +184,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 3;
nameSpecification.SortingReplaceSpaces = true;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 3;
nameSpecification.ReplaceSpaces = true;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
@ -198,7 +198,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("South.Park.-.s05e06.-.City.Sushi.[HDTV-720p]", result);
@ -211,12 +211,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = false;
nameSpecification.SortingIncludeEpisodeTitle = false;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = false;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
var episode = Builder<Episode>.CreateNew()
@ -226,7 +226,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("S15E06", result);
@ -239,13 +239,13 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.SortingMultiEpisodeStyle = 3;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 3;
var episodeOne = Builder<Episode>.CreateNew()
.With(e => e.Title = "Strawberries and Cream (1)")
@ -260,7 +260,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("The Mentalist - S03E23-E24 - Strawberries and Cream [HDTV-720p]", result);
@ -273,13 +273,13 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = false;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 0;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.SortingMultiEpisodeStyle = 2;
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 2;
var episodeOne = Builder<Episode>.CreateNew()
.With(e => e.Title = "Strawberries and Cream (1)")
@ -294,7 +294,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("3x23x24 - Strawberries and Cream [HDTV-720p]", result);
@ -307,13 +307,13 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = false;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 1;
nameSpecification.SortingNumberStyle = 0;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.SortingMultiEpisodeStyle = 2;
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 1;
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 2;
var episodeOne = Builder<Episode>.CreateNew()
.With(e => e.Title = "Strawberries and Cream (1)")
@ -328,7 +328,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("3x23x24 Strawberries and Cream [HDTV-720p]", result);
@ -341,13 +341,13 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 1;
nameSpecification.SortingNumberStyle = 3;
nameSpecification.SortingReplaceSpaces = true;
nameSpecification.SortingMultiEpisodeStyle = 1;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 1;
nameSpecification.NumberStyle = 3;
nameSpecification.ReplaceSpaces = true;
nameSpecification.MultiEpisodeStyle = 1;
var episodeOne = Builder<Episode>.CreateNew()
.With(e => e.Title = "Strawberries and Cream (1)")
@ -362,7 +362,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("The.Mentalist.s03e23.s03e24.Strawberries.and.Cream", result);
@ -375,13 +375,13 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = false;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = true;
nameSpecification.SortingMultiEpisodeStyle = 0;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = false;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = true;
nameSpecification.MultiEpisodeStyle = 0;
var episodeOne = Builder<Episode>.CreateNew()
.With(e => e.Title = "Strawberries and Cream (1)")
@ -396,7 +396,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("The.Mentalist.-.S03E23-24", result);
@ -409,13 +409,13 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = false;
nameSpecification.SortingIncludeEpisodeTitle = false;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 0;
nameSpecification.SortingReplaceSpaces = true;
nameSpecification.SortingMultiEpisodeStyle = 2;
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = false;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = true;
nameSpecification.MultiEpisodeStyle = 2;
var episodeOne = Builder<Episode>.CreateNew()
.With(e => e.Title = "Strawberries and Cream (1)")
@ -430,7 +430,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("3x23x24", result);
@ -441,12 +441,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
{
//Setup
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
@ -455,7 +455,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, true, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = true });
//Assert
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p] [Proper]");
@ -466,12 +466,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
{
//Setup
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
@ -480,7 +480,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p]");
@ -491,12 +491,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
{
//Setup
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
@ -505,7 +505,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, true, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = true });
//Assert
result.Should().Be("South Park - S15E06 - City Sushi");
@ -516,13 +516,13 @@ namespace NzbDrone.Core.Test.OrganizerTests
{
//Setup
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.SortingMultiEpisodeStyle = 3;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 3;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "Hey, Baby, What's Wrong? (1)")
@ -537,7 +537,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
@ -550,12 +550,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 2;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 2;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
@ -564,7 +564,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("South Park.S15E06.City Sushi [HDTV-720p]", result);
@ -577,12 +577,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.SortingIncludeSeriesName = false;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 2;
nameSpecification.SortingNumberStyle = 0;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 2;
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = false;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
@ -591,7 +591,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("15x06.City Sushi [HDTV-720p]", result);
@ -602,13 +602,13 @@ namespace NzbDrone.Core.Test.OrganizerTests
{
//Setup
nameSpecification.SortingIncludeSeriesName = false;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 2;
nameSpecification.SortingNumberStyle = 0;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.SortingUseSceneName = true;
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 2;
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = false;
nameSpecification.UseSceneName = true;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
@ -622,7 +622,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, episodeFile);
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, episodeFile);
//Assert
result.Should().Be(Path.GetFileNameWithoutExtension(episodeFile.Path));
@ -633,13 +633,13 @@ namespace NzbDrone.Core.Test.OrganizerTests
{
//Setup
nameSpecification.SortingIncludeSeriesName = false;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 2;
nameSpecification.SortingNumberStyle = 0;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.SortingUseSceneName = true;
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 2;
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = false;
nameSpecification.UseSceneName = true;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
@ -653,7 +653,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, episodeFile);
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, episodeFile);
//Assert
result.Should().Be(episodeFile.SceneName);
@ -664,13 +664,13 @@ namespace NzbDrone.Core.Test.OrganizerTests
{
//Setup
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.SortingMultiEpisodeStyle = 3;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 3;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "Hey, Baby, What's Wrong? (1)")
@ -685,7 +685,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
@ -696,13 +696,13 @@ namespace NzbDrone.Core.Test.OrganizerTests
{
//Setup
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.SortingMultiEpisodeStyle = 3;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 3;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "Hello")
@ -717,7 +717,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hello + World");
@ -728,13 +728,13 @@ namespace NzbDrone.Core.Test.OrganizerTests
{
//Setup
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.SortingMultiEpisodeStyle = 3;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 3;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "Hello (3)")
@ -755,7 +755,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
//Act
string result = Subject.GetNewFilename(new List<Episode> { episode, episode2, episode3 }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
string result = Subject.BuildFilename(new List<Episode> { episode, episode2, episode3 }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
result.Should().Be("30 Rock - S06E06-E07-E08 - Hello + World");
@ -765,12 +765,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
public void should_use_airDate_if_series_isDaily()
{
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = true;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
var series = Builder<Series>
.CreateNew()
@ -786,7 +786,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
var result = Subject
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
.BuildFilename(episodes, series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13 - Kristen Stewart [HDTV-720p]");
}
@ -794,12 +794,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
public void should_use_airDate_if_series_isDaily_no_episode_title()
{
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = false;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = false;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
var series = Builder<Series>
.CreateNew()
@ -815,7 +815,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
var result = Subject
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
.BuildFilename(episodes, series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13");
}
@ -823,12 +823,12 @@ namespace NzbDrone.Core.Test.OrganizerTests
public void should_set_airdate_to_unknown_if_not_available()
{
nameSpecification.SortingIncludeSeriesName = true;
nameSpecification.SortingIncludeEpisodeTitle = true;
nameSpecification.SortingAppendQuality = false;
nameSpecification.SortingSeparatorStyle = 0;
nameSpecification.SortingNumberStyle = 2;
nameSpecification.SortingReplaceSpaces = false;
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
var series = Builder<Series>
.CreateNew()
@ -844,7 +844,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
.Build();
var result = Subject
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
.BuildFilename(episodes, series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
result.Should().Be("The Daily Show with Jon Stewart - Unknown - Kristen Stewart");
}
}

@ -29,7 +29,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
{
//Setup
var folder = @"C:\Test\DropDir\The Office";
Mocker.GetMock<DiskProvider>().Setup(s => s.GetFiles(folder, SearchOption.AllDirectories))
.Returns(new string[0]);
@ -107,10 +107,10 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
Mocker.GetMock<IEpisodeService>().Setup(s => s.GetEpisodesByFileId(episodeFile.Id))
.Returns(episode);
Mocker.GetMock<IBuildFileNames>().Setup(s => s.GetNewFilename(It.IsAny<IList<Episode>>(), series, Quality.Unknown, false, It.IsAny<EpisodeFile>()))
Mocker.GetMock<IBuildFileNames>().Setup(s => s.BuildFilename(It.IsAny<IList<Episode>>(), series, It.IsAny<EpisodeFile>()))
.Returns(newFilename);
Mocker.GetMock<IBuildFileNames>().Setup(s => s.CalculateFilePath(It.IsAny<Series>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()))
Mocker.GetMock<IBuildFileNames>().Setup(s => s.BuildFilePath(It.IsAny<Series>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()))
.Returns(new FileInfo(newFilePath));
Mocker.GetMock<DiskProvider>()

@ -58,11 +58,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Returns(fakeEpisode);
Mocker.GetMock<IBuildFileNames>()
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Setup(e => e.BuildFilename(fakeEpisode, fakeSeries, It.IsAny<EpisodeFile>()))
.Returns(filename);
Mocker.GetMock<IBuildFileNames>()
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".avi"))
.Setup(e => e.BuildFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".avi"))
.Returns(fi);
//Act
@ -108,11 +108,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Returns(fakeEpisode);
Mocker.GetMock<IBuildFileNames>()
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Setup(e => e.BuildFilename(fakeEpisode, fakeSeries, It.IsAny<EpisodeFile>()))
.Returns(filename);
Mocker.GetMock<IBuildFileNames>()
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
.Setup(e => e.BuildFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
.Returns(fi);
Mocker.GetMock<DiskProvider>()
@ -160,11 +160,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Returns(fakeEpisode);
Mocker.GetMock<IBuildFileNames>()
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Setup(e => e.BuildFilename(fakeEpisode, fakeSeries, It.IsAny<EpisodeFile>()))
.Returns(filename);
Mocker.GetMock<IBuildFileNames>()
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
.Setup(e => e.BuildFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
.Returns(fi);
var result = Mocker.Resolve<DiskScanProvider>().MoveEpisodeFile(file, true);

@ -50,11 +50,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
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.BuildFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), episodeFiles[0]))
.Returns("Title1");
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.BuildFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), episodeFiles[1]))
.Returns("Title2");
//Act
@ -97,11 +97,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
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.BuildFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), episodeFiles[0]))
.Returns("New Title 1");
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.BuildFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), episodeFiles[1]))
.Returns("New Title 2");
//Act
@ -144,11 +144,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
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.BuildFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), episodeFiles[0]))
.Returns("New Title 1");
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.BuildFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), episodeFiles[1]))
.Returns("Title2");
//Act
@ -193,11 +193,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
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.BuildFilename(new List<Episode> { episodes[0], episodes[1] }, It.IsAny<Series>(), episodeFiles[0]))
.Returns("New Title 1");
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.BuildFilename(new List<Episode> { episodes[2] }, It.IsAny<Series>(), episodeFiles[1]))
.Returns("Title2");
//Act
@ -242,11 +242,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
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.BuildFilename(new List<Episode> { episodes[0], episodes[1] }, It.IsAny<Series>(), episodeFiles[0]))
.Returns("Title1");
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.BuildFilename(new List<Episode> { episodes[2] }, It.IsAny<Series>(), episodeFiles[1]))
.Returns("Title2");
//Act

@ -19,30 +19,30 @@ namespace NzbDrone.Core.Organizer
get { return new NameSpecification(); }
}
public bool SortingUseSceneName { get; set; }
public bool UseSceneName { get; set; }
public int SortingSeparatorStyle { get; set; }
public int SeparatorStyle { get; set; }
public int SortingNumberStyle { get; set; }
public int NumberStyle { get; set; }
public bool SortingIncludeSeriesName { get; set; }
public bool IncludeSeriesName { get; set; }
public int SortingMultiEpisodeStyle { get; set; }
public int MultiEpisodeStyle { get; set; }
public bool SortingIncludeEpisodeTitle { get; set; }
public bool IncludeEpisodeTitle { get; set; }
public bool SortingAppendQuality { get; set; }
public bool AppendQuality { get; set; }
public bool SortingReplaceSpaces { get; set; }
public bool ReplaceSpaces { get; set; }
public string SortingSeasonFolderFormat { get; set; }
public string SeasonFolderFormat { 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);
string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile episodeFile);
FileInfo BuildFilePath(Series series, int seasonNumber, string fileName, string extension);
}
public class FileNameBuilder : IBuildFileNames
@ -59,23 +59,15 @@ namespace NzbDrone.Core.Organizer
public NameSpecification GetSpecification()
{
var spec = _nameSpecificationRepository.SingleOrDefault();
if (spec == null)
{
spec = NameSpecification.Default;
}
return spec;
return _nameSpecificationRepository.SingleOrDefault() ?? NameSpecification.Default;
}
public string GetNewFilename(IList<Episode> episodes, Series series, Quality quality, bool proper, EpisodeFile episodeFile)
public string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile episodeFile)
{
var nameSpec = GetSpecification();
if (nameSpec.SortingUseSceneName)
if (nameSpec.UseSceneName)
{
_logger.Trace("Attempting to use scene name");
if (String.IsNullOrWhiteSpace(episodeFile.SceneName))
@ -91,8 +83,8 @@ namespace NzbDrone.Core.Organizer
var sortedEpisodes = episodes.OrderBy(e => e.EpisodeNumber);
var separatorStyle = EpisodeSortingHelper.GetSeparatorStyle(nameSpec.SortingSeparatorStyle);
var numberStyle = EpisodeSortingHelper.GetNumberStyle(nameSpec.SortingNumberStyle);
var separatorStyle = EpisodeSortingHelper.GetSeparatorStyle(nameSpec.SeparatorStyle);
var numberStyle = EpisodeSortingHelper.GetNumberStyle(nameSpec.NumberStyle);
var episodeNames = new List<string>();
@ -100,7 +92,7 @@ namespace NzbDrone.Core.Organizer
string result = String.Empty;
if (nameSpec.SortingIncludeSeriesName)
if (nameSpec.IncludeSeriesName)
{
result += series.Title + separatorStyle.Pattern;
}
@ -113,7 +105,7 @@ namespace NzbDrone.Core.Organizer
if (episodes.Count > 1)
{
var multiEpisodeStyle =
EpisodeSortingHelper.GetMultiEpisodeStyle(nameSpec.SortingMultiEpisodeStyle);
EpisodeSortingHelper.GetMultiEpisodeStyle(nameSpec.MultiEpisodeStyle);
foreach (var episode in sortedEpisodes.Skip(1))
{
@ -147,7 +139,7 @@ namespace NzbDrone.Core.Organizer
result += "Unknown";
}
if (nameSpec.SortingIncludeEpisodeTitle)
if (nameSpec.IncludeEpisodeTitle)
{
if (episodeNames.Distinct().Count() == 1)
result += separatorStyle.Pattern + episodeNames.First();
@ -156,22 +148,22 @@ namespace NzbDrone.Core.Organizer
result += separatorStyle.Pattern + String.Join(" + ", episodeNames.Distinct());
}
if (nameSpec.SortingAppendQuality)
if (nameSpec.AppendQuality)
{
result += String.Format(" [{0}]", quality);
result += String.Format(" [{0}]", episodeFile.Quality);
if (proper)
if (episodeFile.Proper)
result += " [Proper]";
}
if (nameSpec.SortingReplaceSpaces)
if (nameSpec.ReplaceSpaces)
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)
public FileInfo BuildFilePath(Series series, int seasonNumber, string fileName, string extension)
{
var nameSpec = GetSpecification();
@ -179,7 +171,7 @@ namespace NzbDrone.Core.Organizer
string path = series.Path;
if (series.SeasonFolder)
{
var seasonFolder = nameSpec.SortingSeasonFolderFormat
var seasonFolder = nameSpec.SeasonFolderFormat
.Replace("%0s", seasonNumber.ToString("00"))
.Replace("%s", seasonNumber.ToString());

@ -28,7 +28,7 @@ namespace NzbDrone.Core.Providers
private readonly ISeriesRepository _seriesRepository;
private readonly IEventAggregator _eventAggregator;
public DiskScanProvider(DiskProvider diskProvider, IEpisodeService episodeService, IMediaFileService mediaFileService, IConfigService configService,IBuildFileNames buildFileNames,
public DiskScanProvider(DiskProvider diskProvider, IEpisodeService episodeService, IMediaFileService mediaFileService, IConfigService configService, IBuildFileNames buildFileNames,
RecycleBinProvider recycleBinProvider, MediaInfoProvider mediaInfoProvider, ISeriesRepository seriesRepository, IEventAggregator eventAggregator)
{
_diskProvider = diskProvider;
@ -188,8 +188,8 @@ namespace NzbDrone.Core.Providers
var series = _seriesRepository.Get(episodeFile.SeriesId);
var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id);
string newFileName = _buildFileNames.GetNewFilename(episodes, series, episodeFile.Quality, episodeFile.Proper, episodeFile);
var newFile = _buildFileNames.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
string newFileName = _buildFileNames.BuildFilename(episodes, series, episodeFile);
var newFile = _buildFileNames.BuildFilePath(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))

@ -26,7 +26,7 @@ namespace NzbDrone.Core.Providers
}
public virtual List<MisnamedEpisodeModel> MisnamedFiles(int pageNumber, int pageSize, out int totalItems)
{
{
var misnamedFiles = new List<MisnamedEpisodeModel>();
var episodesWithFiles = _episodeService.EpisodesWithFiles().GroupBy(e => e.EpisodeFileId).ToList();
@ -37,17 +37,14 @@ namespace NzbDrone.Core.Providers
var misnamedFilesSelect = episodesWithFiles.AsParallel().Where(
w =>
w.First().EpisodeFile.Path !=
_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);
_buildFileNames.BuildFilename(w.Select(e => e).ToList(), w.First().Series, w.First().EpisodeFile)).Skip(Math.Max(pageSize * (pageNumber - 1), 0)).Take(pageSize);
//Process the episodes
misnamedFilesSelect.AsParallel().ForAll(f =>
{
var episodes = f.Select(e => e).ToList();
var firstEpisode = episodes[0];
var properName = _buildFileNames.GetNewFilename(episodes,
firstEpisode.Series,
firstEpisode.EpisodeFile.Quality, firstEpisode.EpisodeFile.Proper, firstEpisode.EpisodeFile);
var properName = _buildFileNames.BuildFilename(episodes, firstEpisode.Series, firstEpisode.EpisodeFile);
var currentName = Path.GetFileNameWithoutExtension(firstEpisode.EpisodeFile.Path);

Loading…
Cancel
Save