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

@ -107,10 +107,10 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
Mocker.GetMock<IEpisodeService>().Setup(s => s.GetEpisodesByFileId(episodeFile.Id)) Mocker.GetMock<IEpisodeService>().Setup(s => s.GetEpisodesByFileId(episodeFile.Id))
.Returns(episode); .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); .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)); .Returns(new FileInfo(newFilePath));
Mocker.GetMock<DiskProvider>() Mocker.GetMock<DiskProvider>()

@ -58,11 +58,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Returns(fakeEpisode); .Returns(fakeEpisode);
Mocker.GetMock<IBuildFileNames>() 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); .Returns(filename);
Mocker.GetMock<IBuildFileNames>() 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); .Returns(fi);
//Act //Act
@ -108,11 +108,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Returns(fakeEpisode); .Returns(fakeEpisode);
Mocker.GetMock<IBuildFileNames>() 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); .Returns(filename);
Mocker.GetMock<IBuildFileNames>() 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); .Returns(fi);
Mocker.GetMock<DiskProvider>() Mocker.GetMock<DiskProvider>()
@ -160,11 +160,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Returns(fakeEpisode); .Returns(fakeEpisode);
Mocker.GetMock<IBuildFileNames>() 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); .Returns(filename);
Mocker.GetMock<IBuildFileNames>() 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); .Returns(fi);
var result = Mocker.Resolve<DiskScanProvider>().MoveEpisodeFile(file, true); var result = Mocker.Resolve<DiskScanProvider>().MoveEpisodeFile(file, true);

@ -50,11 +50,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes); .Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<IBuildFileNames>() 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"); .Returns("Title1");
Mocker.GetMock<IBuildFileNames>() 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"); .Returns("Title2");
//Act //Act
@ -97,11 +97,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes); .Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<IBuildFileNames>() 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"); .Returns("New Title 1");
Mocker.GetMock<IBuildFileNames>() 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"); .Returns("New Title 2");
//Act //Act
@ -144,11 +144,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes); .Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<IBuildFileNames>() 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"); .Returns("New Title 1");
Mocker.GetMock<IBuildFileNames>() 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"); .Returns("Title2");
//Act //Act
@ -193,11 +193,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes); .Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<IBuildFileNames>() 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"); .Returns("New Title 1");
Mocker.GetMock<IBuildFileNames>() 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"); .Returns("Title2");
//Act //Act
@ -242,11 +242,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.Setup(c => c.EpisodesWithFiles()).Returns(episodes); .Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<IBuildFileNames>() 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"); .Returns("Title1");
Mocker.GetMock<IBuildFileNames>() 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"); .Returns("Title2");
//Act //Act

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

@ -188,8 +188,8 @@ namespace NzbDrone.Core.Providers
var series = _seriesRepository.Get(episodeFile.SeriesId); var series = _seriesRepository.Get(episodeFile.SeriesId);
var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id); var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id);
string newFileName = _buildFileNames.GetNewFilename(episodes, series, episodeFile.Quality, episodeFile.Proper, episodeFile); string newFileName = _buildFileNames.BuildFilename(episodes, series, episodeFile);
var newFile = _buildFileNames.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path)); var newFile = _buildFileNames.BuildFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
//Only rename if existing and new filenames don't match //Only rename if existing and new filenames don't match
if (DiskProvider.PathEquals(episodeFile.Path, newFile.FullName)) if (DiskProvider.PathEquals(episodeFile.Path, newFile.FullName))

@ -37,17 +37,14 @@ namespace NzbDrone.Core.Providers
var misnamedFilesSelect = episodesWithFiles.AsParallel().Where( var misnamedFilesSelect = episodesWithFiles.AsParallel().Where(
w => w =>
w.First().EpisodeFile.Path != w.First().EpisodeFile.Path !=
_buildFileNames.GetNewFilename(w.Select(e => e).ToList(), w.First().Series, _buildFileNames.BuildFilename(w.Select(e => e).ToList(), w.First().Series, w.First().EpisodeFile)).Skip(Math.Max(pageSize * (pageNumber - 1), 0)).Take(pageSize);
w.First().EpisodeFile.Quality, w.First().EpisodeFile.Proper, w.First().EpisodeFile)).Skip(Math.Max(pageSize * (pageNumber - 1), 0)).Take(pageSize);
//Process the episodes //Process the episodes
misnamedFilesSelect.AsParallel().ForAll(f => misnamedFilesSelect.AsParallel().ForAll(f =>
{ {
var episodes = f.Select(e => e).ToList(); var episodes = f.Select(e => e).ToList();
var firstEpisode = episodes[0]; var firstEpisode = episodes[0];
var properName = _buildFileNames.GetNewFilename(episodes, var properName = _buildFileNames.BuildFilename(episodes, firstEpisode.Series, firstEpisode.EpisodeFile);
firstEpisode.Series,
firstEpisode.EpisodeFile.Quality, firstEpisode.EpisodeFile.Proper, firstEpisode.EpisodeFile);
var currentName = Path.GetFileNameWithoutExtension(firstEpisode.EpisodeFile.Path); var currentName = Path.GetFileNameWithoutExtension(firstEpisode.EpisodeFile.Path);

Loading…
Cancel
Save