1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Fixed: Double periods before extensions when episode title ends in a period

This commit is contained in:
Mark McDowall 2014-02-12 00:59:22 -08:00
parent 1cc4c11a7e
commit 1b21f4a2d7
2 changed files with 21 additions and 2 deletions

View File

@ -371,5 +371,22 @@ public void should_be_able_to_use_orginal_title()
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile) Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
.Should().Be("30 Rock - 30.Rock.S01E01.xvid-LOL"); .Should().Be("30 Rock - 30.Rock.S01E01.xvid-LOL");
} }
[Test]
public void should_trim_periods_from_end_of_episode_title()
{
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
_namingConfig.MultiEpisodeStyle = 3;
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "Part 1.")
.With(e => e.SeasonNumber = 6)
.With(e => e.EpisodeNumber = 6)
.Build();
Subject.BuildFilename(new List<Episode> { episode }, new Series { Title = "30 Rock" }, _episodeFile)
.Should().Be("30 Rock - S06E06 - Part 1");
}
} }
} }

View File

@ -44,6 +44,8 @@ public class FileNameBuilder : IBuildFileNames
public static readonly Regex SeriesTitleRegex = new Regex(@"(?<token>\{(?:Series)(?<separator>\s|\.|-|_)Title\})", public static readonly Regex SeriesTitleRegex = new Regex(@"(?<token>\{(?:Series)(?<separator>\s|\.|-|_)Title\})",
RegexOptions.Compiled | RegexOptions.IgnoreCase); RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly char[] EpisodeTitleTrimCharaters = new[] { ' ', '.' };
public FileNameBuilder(INamingConfigService namingConfigService, public FileNameBuilder(INamingConfigService namingConfigService,
IQualityDefinitionService qualityDefinitionService, IQualityDefinitionService qualityDefinitionService,
ICacheManger cacheManger, ICacheManger cacheManger,
@ -88,7 +90,7 @@ public string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile
var pattern = namingConfig.StandardEpisodeFormat; var pattern = namingConfig.StandardEpisodeFormat;
var episodeTitles = new List<string> var episodeTitles = new List<string>
{ {
sortedEpisodes.First().Title sortedEpisodes.First().Title.TrimEnd(EpisodeTitleTrimCharaters)
}; };
var tokenValues = new Dictionary<string, string>(FilenameBuilderTokenEqualityComparer.Instance); var tokenValues = new Dictionary<string, string>(FilenameBuilderTokenEqualityComparer.Instance);
@ -140,7 +142,7 @@ public string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile
break; break;
} }
episodeTitles.Add(episode.Title); episodeTitles.Add(episode.Title.TrimEnd(EpisodeTitleTrimCharaters));
} }
seasonEpisodePattern = ReplaceNumberTokens(seasonEpisodePattern, sortedEpisodes); seasonEpisodePattern = ReplaceNumberTokens(seasonEpisodePattern, sortedEpisodes);