mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-28 23:16:32 -04:00
Fixed: Include extension when calculating maximum episode title length when renaming files
Fixed: Option to override max filename length with MAX_NAME environment variable Closes #3888
This commit is contained in:
+1
-5
@@ -42,11 +42,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeFileMovingServiceTests
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(s => s.BuildFileName(It.IsAny<List<Episode>>(), It.IsAny<Series>(), It.IsAny<EpisodeFile>(), null, null))
|
||||
.Returns("File Name");
|
||||
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
.Setup(s => s.BuildFilePath(It.IsAny<Series>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Setup(s => s.BuildFilePath(It.IsAny<List<Episode>>(), It.IsAny<Series>(), It.IsAny<EpisodeFile>(), It.IsAny<string>(), It.IsAny<NamingConfig>(), It.IsAny<List<string>>()))
|
||||
.Returns(@"C:\Test\TV\Series\Season 01\File Name.avi".AsOsAgnostic());
|
||||
|
||||
Mocker.GetMock<IBuildFileNames>()
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.OrganizerTests
|
||||
@@ -32,16 +34,26 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
||||
[TestCase("30 Rock - S00E05 - Episode Title", 0, true, "Season {season}", @"C:\Test\30 Rock\MySpecials\30 Rock - S00E05 - Episode Title.mkv")]
|
||||
public void CalculateFilePath_SeasonFolder_SingleNumber(string filename, int seasonNumber, bool useSeasonFolder, string seasonFolderFormat, string expectedPath)
|
||||
{
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(s => s.Title = "Episode Title")
|
||||
.With(s => s.SeasonNumber = seasonNumber)
|
||||
.With(s => s.EpisodeNumber = 5)
|
||||
.Build().ToList();
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(s => s.Title = "30 Rock")
|
||||
.With(s => s.Path = @"C:\Test\30 Rock".AsOsAgnostic())
|
||||
.With(s => s.SeasonFolder = useSeasonFolder)
|
||||
.With(s => s.SeriesType = SeriesTypes.Standard)
|
||||
.Build();
|
||||
var fakeEpisodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(s => s.SceneName = filename)
|
||||
.Build();
|
||||
|
||||
namingConfig.SeasonFolderFormat = seasonFolderFormat;
|
||||
namingConfig.SpecialsFolderFormat = "MySpecials";
|
||||
|
||||
Subject.BuildFilePath(fakeSeries, seasonNumber, filename, ".mkv").Should().Be(expectedPath.AsOsAgnostic());
|
||||
Subject.BuildFilePath(fakeEpisodes, fakeSeries, fakeEpisodeFile, ".mkv").Should().Be(expectedPath.AsOsAgnostic());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -51,15 +63,25 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
||||
var seasonNumber = 1;
|
||||
var expectedPath = @"C:\Test\NCIS - Los Angeles\NCIS - Los Angeles Season 1\S01E05 - Episode Title.mkv";
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(s => s.Title = "Episode Title")
|
||||
.With(s => s.SeasonNumber = seasonNumber)
|
||||
.With(s => s.EpisodeNumber = 5)
|
||||
.Build().ToList();
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(s => s.Title = "NCIS: Los Angeles")
|
||||
.With(s => s.Path = @"C:\Test\NCIS - Los Angeles".AsOsAgnostic())
|
||||
.With(s => s.SeasonFolder = true)
|
||||
.With(s => s.SeriesType = SeriesTypes.Standard)
|
||||
.Build();
|
||||
var fakeEpisodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(s => s.SceneName = filename)
|
||||
.Build();
|
||||
|
||||
namingConfig.SeasonFolderFormat = "{Series Title} Season {season:0}";
|
||||
|
||||
Subject.BuildFilePath(fakeSeries, seasonNumber, filename, ".mkv").Should().Be(expectedPath.AsOsAgnostic());
|
||||
|
||||
Subject.BuildFilePath(fakeEpisodes, fakeSeries, fakeEpisodeFile, ".mkv").Should().Be(expectedPath.AsOsAgnostic());
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -93,6 +93,23 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
_episodeFile.Quality.Revision.Version = 2;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_truncate_with_extension()
|
||||
{
|
||||
_series.Title = "The Fantastic Life of Mr. Sisko";
|
||||
|
||||
_episodes[0].SeasonNumber = 2;
|
||||
_episodes[0].EpisodeNumber = 18;
|
||||
_episodes[0].Title = "This title has to be 197 characters in length, combined with the series title, quality and episode number it becomes 254ish and the extension puts it above the 255 limit and triggers the truncation";
|
||||
_episodeFile.Quality.Quality = Quality.Bluray1080p;
|
||||
_episodes = _episodes.Take(1).ToList();
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title} {Quality Full}";
|
||||
|
||||
var result = Subject.BuildFileName(_episodes, _series, _episodeFile, ".mkv");
|
||||
result.Length.Should().BeLessOrEqualTo(255);
|
||||
result.Should().Be("The Fantastic Life of Mr. Sisko - S02E18 - This title has to be 197 characters in length, combined with the series title, quality and episode number it becomes 254ish and the extension puts it above the 255 limit and triggers the trunc... Bluray-1080p.mkv");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_truncate_with_ellipsis_between_first_and_last_episode_titles()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user