From 6452cf8a40f5b655646f5403312607b6c6d91f95 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Tue, 17 Oct 2023 18:25:36 -0500 Subject: [PATCH] fix: Put sonarr version for naming in own column In order to avoid confusion, the `v3` and `v4` version indicators for certain naming format keys has been moved to their own column in the `list` command table. --- CHANGELOG.md | 2 + .../MediaNaming/MediaNamingDataLister.cs | 44 +++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81a536ad..10b62ed4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - CLI: Some custom formats were not properly categorized when running `list custom-formats`. +- Media Naming: In order to avoid confusion, the `v3` and `v4` version indicators for certain naming + format keys has been moved to their own column in the `list` command table. ## [6.0.1] - 2023-10-02 diff --git a/src/Recyclarr.Cli/Pipelines/MediaNaming/MediaNamingDataLister.cs b/src/Recyclarr.Cli/Pipelines/MediaNaming/MediaNamingDataLister.cs index 2095d1bb..a58ac017 100644 --- a/src/Recyclarr.Cli/Pipelines/MediaNaming/MediaNamingDataLister.cs +++ b/src/Recyclarr.Cli/Pipelines/MediaNaming/MediaNamingDataLister.cs @@ -41,9 +41,9 @@ public class MediaNamingDataLister _console.MarkupLine("Media Naming Formats [red](Preview)[/]"); _console.WriteLine(); - _console.Write(DictionaryToTable("Movie Folder Format", guideData.Folder)); + _console.Write(DictionaryToTableRadarr("Movie Folder Format", guideData.Folder)); _console.WriteLine(); - _console.Write(DictionaryToTable("Standard Movie Format", guideData.File)); + _console.Write(DictionaryToTableRadarr("Standard Movie Format", guideData.File)); } private void ListSonarrNaming(SonarrMediaNamingData guideData) @@ -51,18 +51,18 @@ public class MediaNamingDataLister _console.MarkupLine("Media Naming Formats [red](Preview)[/]"); _console.WriteLine(); - _console.Write(DictionaryToTable("Season Folder Format", guideData.Season)); + _console.Write(DictionaryToTableSonarr("Season Folder Format", guideData.Season)); _console.WriteLine(); - _console.Write(DictionaryToTable("Series Folder Format", guideData.Series)); + _console.Write(DictionaryToTableSonarr("Series Folder Format", guideData.Series)); _console.WriteLine(); - _console.Write(DictionaryToTable("Standard Episode Format", guideData.Episodes.Standard)); + _console.Write(DictionaryToTableSonarr("Standard Episode Format", guideData.Episodes.Standard)); _console.WriteLine(); - _console.Write(DictionaryToTable("Daily Episode Format", guideData.Episodes.Daily)); + _console.Write(DictionaryToTableSonarr("Daily Episode Format", guideData.Episodes.Daily)); _console.WriteLine(); - _console.Write(DictionaryToTable("Anime Episode Format", guideData.Episodes.Anime)); + _console.Write(DictionaryToTableSonarr("Anime Episode Format", guideData.Episodes.Anime)); } - private static IRenderable DictionaryToTable(string title, IReadOnlyDictionary formats) + private static IRenderable DictionaryToTableRadarr(string title, IReadOnlyDictionary formats) { var table = new Table() .AddColumns("Key", "Format"); @@ -82,6 +82,34 @@ public class MediaNamingDataLister return new Rows(Markup.FromInterpolated($"[orange3]{title}[/]"), table); } + private static IRenderable DictionaryToTableSonarr(string title, IReadOnlyDictionary formats) + { + var table = new Table() + .AddColumns("Key", "Sonarr Version", "Format"); + + var alternatingColors = new[] {"white", "paleturquoise4"}; + var colorIndex = 0; + + foreach (var (key, value) in formats) + { + var split = key.Split(':'); + var version = split switch + { + {Length: 1} => "All", + _ => $"v{split[1]}" + }; + + var color = alternatingColors[colorIndex]; + table.AddRow( + $"[{color}]{Markup.Escape(split[0])}[/]", + $"[{color}]{Markup.Escape(version)}[/]", + $"[{color}]{Markup.Escape(value)}[/]"); + colorIndex = 1 - colorIndex; + } + + return new Rows(Markup.FromInterpolated($"[orange3]{title}[/]"), table); + } + [SuppressMessage("ReSharper", "ConvertIfStatementToReturnStatement")] private static string TransformKey(string key) {