Merge remote-tracking branch 'origin/master' into quality

pull/19/head
Mark McDowall 12 years ago
commit c5252ca22d

@ -240,7 +240,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("The Mentalist - S03E23-E24 - Strawberries and Cream (1) + Strawberries and Cream (2) [HDTV]", result);
Assert.AreEqual("The Mentalist - S03E23-E24 - Strawberries and Cream [HDTV]", result);
}
[Test]
@ -274,7 +274,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("3x23x24 - Strawberries and Cream (1) + Strawberries and Cream (2) [HDTV]", result);
Assert.AreEqual("3x23x24 - Strawberries and Cream [HDTV]", result);
}
[Test]
@ -308,7 +308,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("3x23x24 Strawberries and Cream (1) + Strawberries and Cream (2) [HDTV]", result);
Assert.AreEqual("3x23x24 Strawberries and Cream [HDTV]", result);
}
[Test]
@ -342,7 +342,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("The.Mentalist.s03e23.s03e24.Strawberries.and.Cream.(1).+.Strawberries.and.Cream.(2)", result);
Assert.AreEqual("The.Mentalist.s03e23.s03e24.Strawberries.and.Cream", result);
}
[Test]
@ -517,7 +517,7 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, "30 Rock", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong! (1) + Hey, Baby, What's Wrong! (2)");
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
}
[Test]
@ -635,5 +635,69 @@ namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
//Assert
result.Should().Be(episodeFile.SceneName);
}
[Test]
public void should_only_have_one_episodeTitle_when_episode_titles_are_the_same()
{
//Setup
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "Hey, Baby, What's Wrong? (1)")
.With(e => e.SeasonNumber = 6)
.With(e => e.EpisodeNumber = 6)
.Build();
var episode2 = Builder<Episode>.CreateNew()
.With(e => e.Title = "Hey, Baby, What's Wrong? (2)")
.With(e => e.SeasonNumber = 6)
.With(e => e.EpisodeNumber = 7)
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, "30 Rock", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
}
[Test]
public void should_have_two_episodeTitles_when_episode_titles_are_not_the_same()
{
//Setup
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
fakeConfig.SetupGet(c => c.SortingMultiEpisodeStyle).Returns(3);
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "Hello")
.With(e => e.SeasonNumber = 6)
.With(e => e.EpisodeNumber = 6)
.Build();
var episode2 = Builder<Episode>.CreateNew()
.With(e => e.Title = "World")
.With(e => e.SeasonNumber = 6)
.With(e => e.EpisodeNumber = 7)
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, "30 Rock", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hello + World");
}
}
}

@ -83,6 +83,8 @@ namespace NzbDrone.Core
RegexOptions.IgnoreCase | RegexOptions.Compiled),
};
private static readonly Regex MultiPartCleanupRegex = new Regex(@"\(\d+\)$", RegexOptions.Compiled);
internal static EpisodeParseResult ParsePath(string path)
{
var fileInfo = new FileInfo(path);
@ -501,5 +503,11 @@ namespace NzbDrone.Core
return header;
}
internal static string CleanupEpisodeTitle(string title)
{
//this will remove (1),(2) from the end of multi part episodes.
return MultiPartCleanupRegex.Replace(title, string.Empty).Trim();
}
}
}

@ -96,13 +96,10 @@ namespace NzbDrone.Core.Providers
}
}
public virtual String GetDownloadTitle(EpisodeParseResult parseResult)
{
var seriesTitle = MediaFileProvider.CleanFilename(parseResult.Series.Title);
//Handle Full Naming
if (parseResult.FullSeason)
{

@ -16,22 +16,17 @@ namespace NzbDrone.Core.Providers
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
//this will remove (1),(2) from the end of multi part episodes.
private static readonly Regex multiPartCleanupRegex = new Regex(@"\(\d+\)$", RegexOptions.Compiled);
private readonly TvDbProvider _tvDbProvider;
private readonly SeasonProvider _seasonProvider;
private readonly IDatabase _database;
private readonly SeriesProvider _seriesProvider;
[Inject]
public EpisodeProvider(IDatabase database, SeriesProvider seriesProvider,
TvDbProvider tvDbProviderProvider, SeasonProvider seasonProvider)
public EpisodeProvider(IDatabase database, TvDbProvider tvDbProviderProvider,
SeasonProvider seasonProvider)
{
_tvDbProvider = tvDbProviderProvider;
_seasonProvider = seasonProvider;
_database = database;
_seriesProvider = seriesProvider;
}
public EpisodeProvider()
@ -228,7 +223,7 @@ namespace NzbDrone.Core.Providers
}
else
{
parseResult.EpisodeTitle = multiPartCleanupRegex.Replace(episodeInfo.Title, string.Empty).Trim();
parseResult.EpisodeTitle = Parser.CleanupEpisodeTitle(episodeInfo.Title);
}
}
else

@ -163,7 +163,9 @@ namespace NzbDrone.Core.Providers
var separatorStyle = EpisodeSortingHelper.GetSeparatorStyle(_configProvider.SortingSeparatorStyle);
var numberStyle = EpisodeSortingHelper.GetNumberStyle(_configProvider.SortingNumberStyle);
string episodeNames = sortedEpisodes.First().Title;
var episodeNames = new List<String>();
episodeNames.Add(Parser.CleanupEpisodeTitle(sortedEpisodes.First().Title));
string result = String.Empty;
@ -190,7 +192,7 @@ namespace NzbDrone.Core.Providers
}
result = result.Replace("%0e", String.Format("{0:00}", episode.EpisodeNumber));
episodeNames += String.Format(" + {0}", episode.Title);
episodeNames.Add(Parser.CleanupEpisodeTitle(episode.Title));
}
}
@ -202,8 +204,11 @@ namespace NzbDrone.Core.Providers
if (_configProvider.SortingIncludeEpisodeTitle)
{
episodeNames = episodeNames.TrimEnd(' ', '+');
result += separatorStyle.Pattern + episodeNames;
if (episodeNames.Distinct().Count() == 1)
result += separatorStyle.Pattern + episodeNames.First();
else
result += separatorStyle.Pattern + String.Join(" + ", episodeNames);
}
if (_configProvider.SortingAppendQuality)

Loading…
Cancel
Save