Don't strip episode count from title if only one episode

pull/6/head
Mark McDowall 11 years ago
parent bedcbf9e70
commit 9e00da4d2a

@ -332,5 +332,17 @@ namespace NzbDrone.Core.Test.OrganizerTests
Subject.BuildFilename(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
.Should().Be("South Park - S15E06-E07 - City Sushi");
}
[Test]
public void should_not_clean_episode_title_if_there_is_only_one()
{
var title = "City Sushi (1)";
_episode1.Title = title;
_namingConfig.StandardEpisodeFormat = "{Episode Title}";
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
.Should().Be(title);
}
}
}

@ -21,7 +21,6 @@ namespace NzbDrone.Core.Organizer
public class FileNameBuilder : IBuildFileNames
{
private readonly IConfigService _configService;
private readonly INamingConfigService _namingConfigService;
private readonly ICached<EpisodeFormat> _patternCache;
private readonly Logger _logger;
@ -41,12 +40,10 @@ namespace NzbDrone.Core.Organizer
public static readonly Regex AirDateRegex = new Regex(@"\{Air(\s|\W|_)Date\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
public FileNameBuilder(INamingConfigService namingConfigService,
IConfigService configService,
ICacheManger cacheManger,
Logger logger)
{
_namingConfigService = namingConfigService;
_configService = configService;
_patternCache = cacheManger.GetCache<EpisodeFormat>(GetType());
_logger = logger;
}
@ -84,7 +81,7 @@ namespace NzbDrone.Core.Organizer
var pattern = namingConfig.StandardEpisodeFormat;
var episodeTitles = new List<string>
{
Parser.Parser.CleanupEpisodeTitle(sortedEpisodes.First().Title)
sortedEpisodes.First().Title
};
var tokenValues = new Dictionary<string, string>(FilenameBuilderTokenEqualityComparer.Instance)
@ -135,14 +132,14 @@ namespace NzbDrone.Core.Organizer
break;
}
episodeTitles.Add(Parser.Parser.CleanupEpisodeTitle(episode.Title));
episodeTitles.Add(episode.Title);
}
seasonEpisodePattern = ReplaceNumberTokens(seasonEpisodePattern, sortedEpisodes);
tokenValues.Add("{Season Episode}", seasonEpisodePattern);
}
tokenValues.Add("{Episode Title}", String.Join(" + ", episodeTitles.Distinct()));
tokenValues.Add("{Episode Title}", GetEpisodeTitle(episodeTitles));
tokenValues.Add("{Quality Title}", episodeFile.Quality.ToString());
@ -314,6 +311,16 @@ namespace NzbDrone.Core.Organizer
return null;
});
}
private string GetEpisodeTitle(List<string> episodeTitles)
{
if (episodeTitles.Count == 1)
{
return episodeTitles.First();
}
return String.Join(" + ", episodeTitles.Select(Parser.Parser.CleanupEpisodeTitle).Distinct());
}
}
public enum MultiEpisodeStyle

Loading…
Cancel
Save