From d3ad970ecc927eeaf286a35a006d887d8f3c7313 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 23 Apr 2023 19:58:05 -0700 Subject: [PATCH] Use enum for MultiEpisodeStyle property --- .../EpisodeTitleCollapseFixture.cs | 2 +- .../FileNameBuilderFixture.cs | 4 +-- .../MultiEpisodeFixture.cs | 34 +++++++++---------- src/NzbDrone.Core/Organizer/NamingConfig.cs | 4 +-- .../Config/NamingExampleResource.cs | 6 ++-- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/EpisodeTitleCollapseFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/EpisodeTitleCollapseFixture.cs index e617ed364..fb76c38ec 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/EpisodeTitleCollapseFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/EpisodeTitleCollapseFixture.cs @@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_not_collapse_episode_titles_when_episode_titles_are_not_the_same() { _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 3; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Scene; _episode1.Title = "Hello"; _episode2.Title = "World"; diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs index a25d43662..521d2d8d9 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs @@ -386,7 +386,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_trim_periods_from_end_of_episode_title() { _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 3; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Scene; var episode = Builder.CreateNew() .With(e => e.Title = "Part 1.") @@ -402,7 +402,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_trim_question_marks_from_end_of_episode_title() { _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 3; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Scene; var episode = Builder.CreateNew() .With(e => e.Title = "Part 1?") diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/MultiEpisodeFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/MultiEpisodeFixture.cs index a352f369b..6776dcfc4 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/MultiEpisodeFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/MultiEpisodeFixture.cs @@ -97,7 +97,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_format_duplicate_multi_episode_properly() { _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 1; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Duplicate; Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) .Should().Be("South Park - S15E06 - S15E07 - City Sushi"); @@ -107,7 +107,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_format_repeat_multi_episode_properly() { _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 2; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Repeat; Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) .Should().Be("South Park - S15E06E07 - City Sushi"); @@ -117,7 +117,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_format_scene_multi_episode_properly() { _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 3; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Scene; Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) .Should().Be("South Park - S15E06-E07 - City Sushi"); @@ -137,7 +137,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_duplicate_absolute_pattern_when_multi_episode_style_is_duplicate() { _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = (int)MultiEpisodeStyle.Duplicate; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Duplicate; _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) @@ -149,7 +149,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests { _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - ({Quality Title}, {MediaInfo Full}, {Release Group}) - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = (int)MultiEpisodeStyle.Duplicate; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Duplicate; Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) .Should().Be("South Park - S15E06 - S15E07 - (HDTV-720p, , SonarrTest) - City Sushi"); @@ -159,7 +159,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_format_range_multi_episode_properly() { _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 4; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Range; Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) .Should().Be("South Park - S15E06-08 - City Sushi"); @@ -169,7 +169,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_format_range_multi_episode_anime_properly() { _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = 4; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Range; _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) @@ -180,7 +180,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_format_repeat_multi_episode_anime_properly() { _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = 2; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Repeat; _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) @@ -191,7 +191,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests 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; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Range; Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) .Should().Be("South Park - S15E06 - City Sushi"); @@ -201,7 +201,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_format_single_anime_episode_with_range_multi_episode_properly() { _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = 4; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Range; _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) @@ -212,7 +212,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_default_to_dash_when_serparator_is_not_set_for_absolute_number() { _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = (int)MultiEpisodeStyle.Duplicate; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Duplicate; _namingConfig.AnimeEpisodeFormat = "{Series Title} - {season}x{episode:00} - [{absolute:000}] - {Episode Title} - {Quality Title}"; Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) @@ -223,7 +223,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_format_prefixed_range_multi_episode_properly() { _namingConfig.StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 5; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.PrefixedRange; Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) .Should().Be("South Park - S15E06-E08 - City Sushi"); @@ -233,7 +233,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_format_prefixed_range_multi_episode_anime_properly() { _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = 5; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.PrefixedRange; _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) @@ -244,7 +244,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests 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; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.PrefixedRange; Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) .Should().Be("South Park - S15E06 - City Sushi"); @@ -254,7 +254,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_format_single_anime_episode_with_prefixed_range_multi_episode_properly() { _series.SeriesType = SeriesTypes.Anime; - _namingConfig.MultiEpisodeStyle = 5; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.PrefixedRange; _namingConfig.AnimeEpisodeFormat = "{Series Title} - {absolute:000} - {Episode Title}"; Subject.BuildFileName(new List { _episode1 }, _series, _episodeFile) @@ -265,7 +265,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests 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; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.PrefixedRange; Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) .Should().Be("South Park - 15x06-x08 - City Sushi"); @@ -275,7 +275,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests public void should_format_range_multi_episode_wrapped_in_brackets() { _namingConfig.StandardEpisodeFormat = "{Series Title} (S{season:00}E{episode:00}) {Episode Title}"; - _namingConfig.MultiEpisodeStyle = 4; + _namingConfig.MultiEpisodeStyle = MultiEpisodeStyle.Range; Subject.BuildFileName(new List { _episode1, _episode2, _episode3 }, _series, _episodeFile) .Should().Be("South Park (S15E06-08) City Sushi"); diff --git a/src/NzbDrone.Core/Organizer/NamingConfig.cs b/src/NzbDrone.Core/Organizer/NamingConfig.cs index 9268ff1c9..50f5d254c 100644 --- a/src/NzbDrone.Core/Organizer/NamingConfig.cs +++ b/src/NzbDrone.Core/Organizer/NamingConfig.cs @@ -8,7 +8,7 @@ namespace NzbDrone.Core.Organizer { RenameEpisodes = false, ReplaceIllegalCharacters = true, - MultiEpisodeStyle = 5, + MultiEpisodeStyle = MultiEpisodeStyle.PrefixedRange, StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title} {Quality Full}", DailyEpisodeFormat = "{Series Title} - {Air-Date} - {Episode Title} {Quality Full}", AnimeEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title} {Quality Full}", @@ -19,7 +19,7 @@ namespace NzbDrone.Core.Organizer public bool RenameEpisodes { get; set; } public bool ReplaceIllegalCharacters { get; set; } - public int MultiEpisodeStyle { get; set; } + public MultiEpisodeStyle MultiEpisodeStyle { get; set; } public string StandardEpisodeFormat { get; set; } public string DailyEpisodeFormat { get; set; } public string AnimeEpisodeFormat { get; set; } diff --git a/src/Sonarr.Api.V3/Config/NamingExampleResource.cs b/src/Sonarr.Api.V3/Config/NamingExampleResource.cs index 4eb98c87a..103609d5d 100644 --- a/src/Sonarr.Api.V3/Config/NamingExampleResource.cs +++ b/src/Sonarr.Api.V3/Config/NamingExampleResource.cs @@ -1,4 +1,4 @@ -using NzbDrone.Core.Organizer; +using NzbDrone.Core.Organizer; namespace Sonarr.Api.V3.Config { @@ -24,7 +24,7 @@ namespace Sonarr.Api.V3.Config RenameEpisodes = model.RenameEpisodes, ReplaceIllegalCharacters = model.ReplaceIllegalCharacters, - MultiEpisodeStyle = model.MultiEpisodeStyle, + MultiEpisodeStyle = (int)model.MultiEpisodeStyle, StandardEpisodeFormat = model.StandardEpisodeFormat, DailyEpisodeFormat = model.DailyEpisodeFormat, AnimeEpisodeFormat = model.AnimeEpisodeFormat, @@ -59,7 +59,7 @@ namespace Sonarr.Api.V3.Config RenameEpisodes = resource.RenameEpisodes, ReplaceIllegalCharacters = resource.ReplaceIllegalCharacters, - MultiEpisodeStyle = resource.MultiEpisodeStyle, + MultiEpisodeStyle = (MultiEpisodeStyle)resource.MultiEpisodeStyle, StandardEpisodeFormat = resource.StandardEpisodeFormat, DailyEpisodeFormat = resource.DailyEpisodeFormat, AnimeEpisodeFormat = resource.AnimeEpisodeFormat,