Fixed: Original Filename/Title not being included when importing a new file

Closes #5010
This commit is contained in:
Mark McDowall 2022-05-09 21:04:42 -07:00
parent 704cf7aebe
commit d01e6d32de
2 changed files with 39 additions and 12 deletions

View File

@ -34,7 +34,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
.With(e => e.AbsoluteEpisodeNumber = 100)
.Build();
_episodeFile = new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p), ReleaseGroup = "SonarrTest" };
_episodeFile = new EpisodeFile { Id = 5, Quality = new QualityModel(Quality.HDTV720p), ReleaseGroup = "SonarrTest" };
_namingConfig = NamingConfig.Default;
_namingConfig.RenameEpisodes = true;
@ -47,16 +47,6 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
.Returns<Quality>(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v));
}
[Test]
public void should_not_recursively_include_current_filename()
{
_episodeFile.RelativePath = "My Series - S15E06 - City Sushi";
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title} {[Original Title]}";
Subject.BuildFileName(new List<Episode> { _episode }, _series, _episodeFile)
.Should().Be("My Series - S15E06 - City Sushi");
}
[Test]
public void should_include_original_title_if_not_current_file_name()
{
@ -145,5 +135,42 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
Subject.BuildFileName(new List<Episode> { _episode }, _series, _episodeFile)
.Should().Be("My Series - 123");
}
[Test]
public void should_include_current_filename_for_new_file_if_including_season_and_episode_tokens_for_standard_series()
{
_episodeFile.Id = 0;
_episodeFile.RelativePath = "My Series - S15E06 - City Sushi";
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} {[Original Title]}";
Subject.BuildFileName(new List<Episode> { _episode }, _series, _episodeFile)
.Should().Be("My Series - S15E06 [My Series - S15E06 - City Sushi]");
}
[Test]
public void should_include_current_filename_for_new_file_if_including_air_date_token_for_daily_series()
{
_series.SeriesType = SeriesTypes.Daily;
_episode.AirDate = "2022-04-28";
_episodeFile.Id = 0;
_episodeFile.RelativePath = "My Series - 2022-04-28 - City Sushi";
_namingConfig.DailyEpisodeFormat = "{Series Title} - {Air-Date} {[Original Title]}";
Subject.BuildFileName(new List<Episode> { _episode }, _series, _episodeFile)
.Should().Be("My Series - 2022-04-28 [My Series - 2022-04-28 - City Sushi]");
}
[Test]
public void should_include_current_filename_for_new_file_if_including_absolute_episode_number_token_for_anime_series()
{
_series.SeriesType = SeriesTypes.Anime;
_episode.AbsoluteEpisodeNumber = 123;
_episodeFile.Id = 0;
_episodeFile.RelativePath = "My Series - 123 - City Sushi";
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:00} {[Original Title]}";
Subject.BuildFileName(new List<Episode> { _episode }, _series, _episodeFile)
.Should().Be("My Series - 123 [My Series - 123 - City Sushi]");
}
}
}

View File

@ -161,7 +161,7 @@ namespace NzbDrone.Core.Organizer
AddIdTokens(tokenHandlers, series);
AddEpisodeTokens(tokenHandlers, episodes);
AddEpisodeTitlePlaceholderTokens(tokenHandlers);
AddEpisodeFileTokens(tokenHandlers, episodeFile, !patternHasEpisodeIdentifier);
AddEpisodeFileTokens(tokenHandlers, episodeFile, !patternHasEpisodeIdentifier || episodeFile.Id == 0);
AddQualityTokens(tokenHandlers, series, episodeFile);
AddMediaInfoTokens(tokenHandlers, episodeFile);
AddPreferredWords(tokenHandlers, series, episodeFile, preferredWords);