Don't use Sonarr as ReleaseGroup if the pattern contains an advanced prefix/suffix.

pull/3113/head
Taloth Saldono 9 years ago
parent 59c68ec6cc
commit f005edfcf0

@ -712,6 +712,18 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
.Should().Be("Sonarr");
}
[TestCase("{Episode Title}{-Release Group}", "City Sushi")]
[TestCase("{Episode Title}{ Release Group}", "City Sushi")]
[TestCase("{Episode Title}{ [Release Group]}", "City Sushi")]
public void should_not_use_Sonarr_as_release_group_if_pattern_has_separator(string pattern, string expectedFileName)
{
_episodeFile.ReleaseGroup = null;
_namingConfig.StandardEpisodeFormat = pattern;
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
.Should().Be(expectedFileName);
}
[TestCase("0SEC")]
[TestCase("2HD")]
[TestCase("IMMERSE")]

@ -425,7 +425,7 @@ namespace NzbDrone.Core.Organizer
{
tokenHandlers["{Original Title}"] = m => GetOriginalTitle(episodeFile);
tokenHandlers["{Original Filename}"] = m => GetOriginalFileName(episodeFile);
tokenHandlers["{Release Group}"] = m => episodeFile.ReleaseGroup ?? "Sonarr";
tokenHandlers["{Release Group}"] = m => episodeFile.ReleaseGroup ?? m.DefaultValue("Sonarr");
}
private void AddQualityTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Series series, EpisodeFile episodeFile)
@ -759,6 +759,18 @@ namespace NzbDrone.Core.Organizer
public string Suffix { get; set; }
public string Token { get; set; }
public string CustomFormat { get; set; }
public string DefaultValue(string defaultValue)
{
if (string.IsNullOrEmpty(Prefix) && string.IsNullOrEmpty(Suffix))
{
return defaultValue;
}
else
{
return string.Empty;
}
}
}
public enum MultiEpisodeStyle

Loading…
Cancel
Save