1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

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

This commit is contained in:
Mark McDowall 2013-11-30 21:49:40 -08:00
parent bedcbf9e70
commit 9e00da4d2a
2 changed files with 27 additions and 8 deletions

View File

@ -332,5 +332,17 @@ public void should_format_scene_multi_episode_properly()
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);
}
}
}

View File

@ -21,7 +21,6 @@ public interface IBuildFileNames
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 @@ public class FileNameBuilder : IBuildFileNames
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 @@ public string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile
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 @@ public string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile
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 @@ private EpisodeFormat GetEpisodeFormat(string pattern)
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