Fixed: Using absolute episode number in Standard Format for episode without while renaming

pull/5428/head
Mark McDowall 2 years ago
parent 69f325b9dd
commit 72b307f4ad

@ -83,5 +83,16 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
Subject.BuildFileName(new List<Episode> { _episode }, _series, _episodeFile)
.Should().Be("Anime Series S15E06 [SonarrTest]");
}
[Test]
public void should_use_standard_format_without_absolute_numbering_if_absolute_format_requires_absolute_episode_number_and_it_is_missing()
{
_episode.AbsoluteEpisodeNumber = null;
_namingConfig.StandardEpisodeFormat = "{Series Title} S{season:00}E{episode:00} - {absolute:00}";
_namingConfig.AnimeEpisodeFormat = "{Series Title} {absolute:00} [{ReleaseGroup}]";
Subject.BuildFileName(new List<Episode> { _episode }, _series, _episodeFile)
.Should().Be("Anime Series S15E06");
}
}
}

@ -70,7 +70,7 @@ namespace NzbDrone.Core.Organizer
RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex FileNameCleanupRegex = new Regex(@"([- ._])(\1)+", RegexOptions.Compiled);
private static readonly Regex TrimSeparatorsRegex = new Regex(@"[- ._]$", RegexOptions.Compiled);
private static readonly Regex TrimSeparatorsRegex = new Regex(@"[- ._]+$", RegexOptions.Compiled);
private static readonly Regex ScenifyRemoveChars = new Regex(@"(?<=\s)(,|<|>|\/|\\|;|:|'|""|\||`|~|!|\?|@|$|%|^|\*|-|_|=){1}(?=\s)|('|:|\?|,)(?=(?:(?:s|m)\s)|\s|$)|(\(|\)|\[|\]|\{|\})", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex ScenifyReplaceChars = new Regex(@"[\/]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
@ -540,7 +540,7 @@ namespace NzbDrone.Core.Organizer
int index = 1;
foreach (var absoluteEpisodeFormat in absoluteEpisodeFormats)
{
if (series.SeriesType != SeriesTypes.Anime)
if (series.SeriesType != SeriesTypes.Anime || episodes.Any(e => !e.AbsoluteEpisodeNumber.HasValue))
{
pattern = pattern.Replace(absoluteEpisodeFormat.AbsoluteEpisodePattern, "");
continue;

Loading…
Cancel
Save