mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 07:22:35 +01:00
New: Prefixed Range multi-episode style (for plex)
This commit is contained in:
parent
8a41a4c91e
commit
03b5095b06
@ -36,7 +36,7 @@ namespace NzbDrone.Api.Config
|
||||
|
||||
Get["/samples"] = x => GetExamples(this.Bind<NamingConfigResource>());
|
||||
|
||||
SharedValidator.RuleFor(c => c.MultiEpisodeStyle).InclusiveBetween(0, 4);
|
||||
SharedValidator.RuleFor(c => c.MultiEpisodeStyle).InclusiveBetween(0, 5);
|
||||
SharedValidator.RuleFor(c => c.StandardEpisodeFormat).ValidEpisodeFormat();
|
||||
SharedValidator.RuleFor(c => c.DailyEpisodeFormat).ValidDailyEpisodeFormat();
|
||||
SharedValidator.RuleFor(c => c.AnimeEpisodeFormat).ValidAnimeEpisodeFormat();
|
||||
|
@ -231,6 +231,7 @@
|
||||
<Compile Include="MetadataSourceTests\SearchSeriesComparerFixture.cs" />
|
||||
<Compile Include="OrganizerTests\FileNameBuilderTests\CleanTitleFixture.cs" />
|
||||
<Compile Include="OrganizerTests\FileNameBuilderTests\EpisodeTitleCollapseFixture.cs" />
|
||||
<Compile Include="OrganizerTests\FileNameBuilderTests\MultiEpisodeFixture.cs" />
|
||||
<Compile Include="ParserTests\MiniSeriesEpisodeParserFixture.cs" />
|
||||
<Compile Include="Qualities\RevisionComparableFixture.cs" />
|
||||
<Compile Include="RemotePathMappingsTests\RemotePathMappingServiceFixture.cs" />
|
||||
|
@ -19,8 +19,6 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
{
|
||||
private Series _series;
|
||||
private Episode _episode1;
|
||||
private Episode _episode2;
|
||||
private Episode _episode3;
|
||||
private EpisodeFile _episodeFile;
|
||||
private NamingConfig _namingConfig;
|
||||
|
||||
@ -47,20 +45,6 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
.With(e => e.AbsoluteEpisodeNumber = 100)
|
||||
.Build();
|
||||
|
||||
_episode2 = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
.With(e => e.SeasonNumber = 15)
|
||||
.With(e => e.EpisodeNumber = 7)
|
||||
.With(e => e.AbsoluteEpisodeNumber = 101)
|
||||
.Build();
|
||||
|
||||
_episode3 = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
.With(e => e.SeasonNumber = 15)
|
||||
.With(e => e.EpisodeNumber = 8)
|
||||
.With(e => e.AbsoluteEpisodeNumber = 102)
|
||||
.Build();
|
||||
|
||||
_episodeFile = new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p), ReleaseGroup = "SonarrTest" };
|
||||
|
||||
Mocker.GetMock<IQualityDefinitionService>()
|
||||
@ -294,46 +278,6 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
.Should().Be("The Daily Show with Jon Stewart - Unknown - Kristen Stewart");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_extend_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 0;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> {_episode1, _episode2}, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06-07 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_duplicate_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 1;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06 - S15E07 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_repeat_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 2;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06E07 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_scene_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 3;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06-E07 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_clean_episode_title_if_there_is_only_one()
|
||||
{
|
||||
@ -487,18 +431,8 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} Season {season:0000} Episode {episode:0000}\\{Series.Title}.S{season:00}E{episode:00}.{absolute:00}.{Episode.Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park Season 0015 Episode 0006-0007\\South.Park.S15E06-07.100-101.City.Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_dash_as_separator_when_multi_episode_style_is_extend_for_anime()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100-101 - City Sushi");
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South Park Season 0015 Episode 0006\\South.Park.S15E06.100.City.Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -514,17 +448,6 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
.Should().Be("South Park - 15x06 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_duplicate_absolute_pattern_when_multi_episode_style_is_duplicate()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.MultiEpisodeStyle = (int)MultiEpisodeStyle.Duplicate;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2, _episode3 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100 - 101 - 102 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_include_affixes_if_value_not_empty()
|
||||
{
|
||||
@ -602,17 +525,6 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
.Should().Be(Path.GetFileNameWithoutExtension(_episodeFile.RelativePath));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_proper_filename_when_multi_episode_is_duplicated_and_bracket_follows_pattern()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat =
|
||||
"{Series Title} - S{season:00}E{episode:00} - ({Quality Title}, {MediaInfo Full}, {Release Group}) - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = (int) MultiEpisodeStyle.Duplicate;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06 - S15E07 - (HDTV-720p, , SonarrTest) - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_use_only_original_title()
|
||||
{
|
||||
@ -644,17 +556,6 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
.Should().Be("South Park - S15 E06 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_default_to_dash_when_serparator_is_not_set_for_absolute_number()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.MultiEpisodeStyle = (int)MultiEpisodeStyle.Duplicate;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {season}x{episode:00} - [{absolute:000}] - {Episode Title} - {Quality Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 15x06 - 15x07 - [100-101] - City Sushi - HDTV-720p");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_replace_quality_proper_with_v2_for_anime_v2()
|
||||
{
|
||||
@ -740,59 +641,6 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
.Should().Be(String.Format("HDTV-720p{0}City{0}Sushi", separator));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_range_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 4;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2, _episode3 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06-08 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_range_multi_episode_anime_properly()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.MultiEpisodeStyle = 4;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2, _episode3 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100-102 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_repeat_multi_episode_anime_properly()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.MultiEpisodeStyle = 2;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2, _episode3 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100-101-102 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_single_episode_with_range_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 4;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_single_anime_episode_with_range_multi_episode_properly()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.MultiEpisodeStyle = 4;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_require_a_separator_between_tokens()
|
||||
{
|
||||
|
@ -0,0 +1,273 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
{
|
||||
[TestFixture]
|
||||
|
||||
public class MultiEpisodeFixture : CoreTest<FileNameBuilder>
|
||||
{
|
||||
private Series _series;
|
||||
private Episode _episode1;
|
||||
private Episode _episode2;
|
||||
private Episode _episode3;
|
||||
private EpisodeFile _episodeFile;
|
||||
private NamingConfig _namingConfig;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>
|
||||
.CreateNew()
|
||||
.With(s => s.Title = "South Park")
|
||||
.Build();
|
||||
|
||||
|
||||
_namingConfig = new NamingConfig();
|
||||
_namingConfig.RenameEpisodes = true;
|
||||
|
||||
|
||||
Mocker.GetMock<INamingConfigService>()
|
||||
.Setup(c => c.GetConfig()).Returns(_namingConfig);
|
||||
|
||||
_episode1 = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
.With(e => e.SeasonNumber = 15)
|
||||
.With(e => e.EpisodeNumber = 6)
|
||||
.With(e => e.AbsoluteEpisodeNumber = 100)
|
||||
.Build();
|
||||
|
||||
_episode2 = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
.With(e => e.SeasonNumber = 15)
|
||||
.With(e => e.EpisodeNumber = 7)
|
||||
.With(e => e.AbsoluteEpisodeNumber = 101)
|
||||
.Build();
|
||||
|
||||
_episode3 = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "City Sushi")
|
||||
.With(e => e.SeasonNumber = 15)
|
||||
.With(e => e.EpisodeNumber = 8)
|
||||
.With(e => e.AbsoluteEpisodeNumber = 102)
|
||||
.Build();
|
||||
|
||||
_episodeFile = new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p), ReleaseGroup = "SonarrTest" };
|
||||
|
||||
Mocker.GetMock<IQualityDefinitionService>()
|
||||
.Setup(v => v.Get(Moq.It.IsAny<Quality>()))
|
||||
.Returns<Quality>(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v));
|
||||
}
|
||||
|
||||
private void GivenProper()
|
||||
{
|
||||
_episodeFile.Quality.Revision.Version = 2;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_replace_Series_space_Title()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> {_episode1}, _series, _episodeFile)
|
||||
.Should().Be("South Park");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_extend_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 0;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> {_episode1, _episode2}, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06-07 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_duplicate_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 1;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06 - S15E07 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_repeat_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 2;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06E07 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_scene_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 3;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06-E07 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_dash_as_separator_when_multi_episode_style_is_extend_for_anime()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100-101 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_duplicate_absolute_pattern_when_multi_episode_style_is_duplicate()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.MultiEpisodeStyle = (int)MultiEpisodeStyle.Duplicate;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2, _episode3 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100 - 101 - 102 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_proper_filename_when_multi_episode_is_duplicated_and_bracket_follows_pattern()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat =
|
||||
"{Series Title} - S{season:00}E{episode:00} - ({Quality Title}, {MediaInfo Full}, {Release Group}) - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = (int) MultiEpisodeStyle.Duplicate;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06 - S15E07 - (HDTV-720p, , SonarrTest) - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_range_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 4;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2, _episode3 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06-08 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_range_multi_episode_anime_properly()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.MultiEpisodeStyle = 4;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2, _episode3 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100-102 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_repeat_multi_episode_anime_properly()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.MultiEpisodeStyle = 2;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2, _episode3 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100-101-102 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_single_episode_with_range_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 4;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_single_anime_episode_with_range_multi_episode_properly()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.MultiEpisodeStyle = 4;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_default_to_dash_when_serparator_is_not_set_for_absolute_number()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.MultiEpisodeStyle = (int)MultiEpisodeStyle.Duplicate;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {season}x{episode:00} - [{absolute:000}] - {Episode Title} - {Quality Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 15x06 - 15x07 - [100-101] - City Sushi - HDTV-720p");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_prefixed_range_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 5;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2, _episode3 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06-E08 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_prefixed_range_multi_episode_anime_properly()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.MultiEpisodeStyle = 5;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2, _episode3 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100-102 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_single_episode_with_prefixed_range_multi_episode_properly()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 5;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - S15E06 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_single_anime_episode_with_prefixed_range_multi_episode_properly()
|
||||
{
|
||||
_series.SeriesType = SeriesTypes.Anime;
|
||||
_namingConfig.MultiEpisodeStyle = 5;
|
||||
_namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}";
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 100 - City Sushi");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_format_prefixed_range_multi_episode_using_episode_separator()
|
||||
{
|
||||
_namingConfig.StandardEpisodeFormat = "{Series Title} - {season:0}x{episode:00} - {Episode Title}";
|
||||
_namingConfig.MultiEpisodeStyle = 5;
|
||||
|
||||
Subject.BuildFileName(new List<Episode> { _episode1, _episode2, _episode3 }, _series, _episodeFile)
|
||||
.Should().Be("South Park - 15E06-x08 - City Sushi");
|
||||
}
|
||||
}
|
||||
}
|
@ -301,11 +301,12 @@ namespace NzbDrone.Core.Organizer
|
||||
|
||||
case MultiEpisodeStyle.Range:
|
||||
formatPattern = "-" + episodeFormat.EpisodePattern;
|
||||
var eps = new List<Episode> { episodes.First() };
|
||||
seasonEpisodePattern = FormatRangeNumberTokens(seasonEpisodePattern, formatPattern, episodes);
|
||||
break;
|
||||
|
||||
if (episodes.Count > 1) eps.Add(episodes.Last());
|
||||
|
||||
seasonEpisodePattern = FormatNumberTokens(seasonEpisodePattern, formatPattern, eps);
|
||||
case MultiEpisodeStyle.PrefixedRange:
|
||||
formatPattern = "-" + episodeFormat.EpisodeSeparator + episodeFormat.EpisodePattern;
|
||||
seasonEpisodePattern = FormatRangeNumberTokens(seasonEpisodePattern, formatPattern, episodes);
|
||||
break;
|
||||
|
||||
//MultiEpisodeStyle.Extend
|
||||
@ -371,6 +372,7 @@ namespace NzbDrone.Core.Organizer
|
||||
break;
|
||||
|
||||
case MultiEpisodeStyle.Range:
|
||||
case MultiEpisodeStyle.PrefixedRange:
|
||||
formatPattern = "-" + absoluteEpisodeFormat.AbsoluteEpisodePattern;
|
||||
var eps = new List<Episode> {episodes.First()};
|
||||
|
||||
@ -612,6 +614,15 @@ namespace NzbDrone.Core.Organizer
|
||||
return ReplaceSeasonTokens(pattern, episodes.First().SeasonNumber);
|
||||
}
|
||||
|
||||
private string FormatRangeNumberTokens(string seasonEpisodePattern, string formatPattern, List<Episode> episodes)
|
||||
{
|
||||
var eps = new List<Episode> { episodes.First() };
|
||||
|
||||
if (episodes.Count > 1) eps.Add(episodes.Last());
|
||||
|
||||
return FormatNumberTokens(seasonEpisodePattern, formatPattern, eps);
|
||||
}
|
||||
|
||||
private string ReplaceSeasonTokens(string pattern, int seasonNumber)
|
||||
{
|
||||
return SeasonRegex.Replace(pattern, match => ReplaceNumberToken(match.Groups["season"].Value, seasonNumber));
|
||||
@ -722,6 +733,7 @@ namespace NzbDrone.Core.Organizer
|
||||
Duplicate = 1,
|
||||
Repeat = 2,
|
||||
Scene = 3,
|
||||
Range = 4
|
||||
Range = 4,
|
||||
PrefixedRange = 5
|
||||
}
|
||||
}
|
||||
|
@ -176,6 +176,7 @@
|
||||
<option value="2">Repeat</option>
|
||||
<option value="3">Scene</option>
|
||||
<option value="4">Range</option>
|
||||
<option value="5">Prefixed Range</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user