From 3e3da2298e4e88f611fbbbdbe6ad47eed6ede855 Mon Sep 17 00:00:00 2001 From: Jo-Be-Co Date: Fri, 3 Apr 2026 03:41:01 +0200 Subject: [PATCH] Add `` --- .../Templates/LibraryBookDto.cs | 1 + .../Templates/TemplateTags.cs | 1 + .../LibationFileManager/Templates/Templates.cs | 1 + .../TemplatesTests.cs | 18 ++++++++++++------ docs/features/naming-templates.md | 3 ++- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Source/LibationFileManager/Templates/LibraryBookDto.cs b/Source/LibationFileManager/Templates/LibraryBookDto.cs index f935300b..29b98b01 100644 --- a/Source/LibationFileManager/Templates/LibraryBookDto.cs +++ b/Source/LibationFileManager/Templates/LibraryBookDto.cs @@ -45,4 +45,5 @@ public class LibraryBookDto : BookDto public string? Account { get; set; } public string? AccountNickname { get; set; } public IEnumerable? Tags { get; set; } + public string? FirstTag => Tags?.FirstOrDefault()?.Value; } diff --git a/Source/LibationFileManager/Templates/TemplateTags.cs b/Source/LibationFileManager/Templates/TemplateTags.cs index fbde92f4..5c6cdf68 100644 --- a/Source/LibationFileManager/Templates/TemplateTags.cs +++ b/Source/LibationFileManager/Templates/TemplateTags.cs @@ -44,6 +44,7 @@ public sealed class TemplateTags : ITemplateTag public static TemplateTags Account { get; } = new("account", "Audible account of this book"); public static TemplateTags AccountNickname { get; } = new("account nickname", "Audible account nickname of this book"); public static TemplateTags Tag { get; } = new("tag", "Tag(s)"); + public static TemplateTags FirstTag { get; } = new("first tag", "First tag"); public static TemplateTags Locale { get; } = new("locale", "Region/country"); public static TemplateTags YearPublished { get; } = new("year", "Year published"); public static TemplateTags Language { get; } = new("language", "Book's language"); diff --git a/Source/LibationFileManager/Templates/Templates.cs b/Source/LibationFileManager/Templates/Templates.cs index 255a67a7..186dcfb4 100644 --- a/Source/LibationFileManager/Templates/Templates.cs +++ b/Source/LibationFileManager/Templates/Templates.cs @@ -289,6 +289,7 @@ public abstract class Templates { TemplateTags.DateAdded, lb => lb.DateAdded }, { TemplateTags.FileDate, lb => lb.FileDate }, { TemplateTags.Tag, lb => lb.Tags, StringListFormat.Formatter, StringListFormat.Finalizer }, + { TemplateTags.FirstTag, lb => lb.FirstTag }, }; private static readonly PropertyTagCollection audioFilePropertyTags = diff --git a/Source/_Tests/LibationFileManager.Tests/TemplatesTests.cs b/Source/_Tests/LibationFileManager.Tests/TemplatesTests.cs index 06f057e0..ee97d4bb 100644 --- a/Source/_Tests/LibationFileManager.Tests/TemplatesTests.cs +++ b/Source/_Tests/LibationFileManager.Tests/TemplatesTests.cs @@ -524,6 +524,9 @@ namespace TemplatesTests [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] + [DataRow("true<-has>", "true")] + [DataRow("true<-has>", "true")] + [DataRow("false<-has>", "")] [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] @@ -719,9 +722,9 @@ namespace TemplatesTests [DataRow("", "İ", "tr-TR", "i")] [DataRow(@"", "8.573,30E1-0.021,00-9", "es-ES", "any")] [DataRow(@"", "8,573.30E1-0,021.00-9", "en-AU", "any")] - [DataRow(@"", "44,100Hz ", "en-CA", "any")] - [DataRow(@"", "44’100Hz ", "de-CH", "any")] - [DataRow(@"", "44\u00A0100Hz ", "fr-CA", "any")] // non-breaking-space + [DataRow("", "44,100Hz ", "en-CA", "any")] + [DataRow("", "44’100Hz ", "de-CH", "any")] + [DataRow("", "44\u00A0100Hz ", "fr-CA", "any")] // non-breaking-space public void Tag_culture_test(string template, string expected, string cultureName, string title) { var bookDto = Shared.GetLibraryBook(); @@ -740,11 +743,14 @@ namespace TemplatesTests [DataRow("", "Tag1, Tag2, Tag3")] [DataRow("", "Tag1 - Tag2 - Tag3")] [DataRow("", "TAG1, TAG2, TAG3")] - [DataRow("", "tag1, tag2, tag3")] - [DataRow("", "Tag: Tag1, Tag: Tag2, Tag: Tag3")] + [DataRow("", "tag1, tag2, tag3")] + [DataRow("", "Tag: Tag1, Tag: Tag2, Tag: Tag3")] [DataRow("", "Tag1")] [DataRow("", "Tag2, Tag3")] - [DataRow("", "Tag3, Tag2, Tag1")] + [DataRow("", "Tag3, Tag2, Tag1")] + [DataRow("", "Tag1")] + [DataRow("", "Tag1")] + [DataRow("", "tag1")] public void Tag_test(string template, string expected) { var bookDto = Shared.GetLibraryBook(); diff --git a/docs/features/naming-templates.md b/docs/features/naming-templates.md index a69db722..6917ec06 100644 --- a/docs/features/naming-templates.md +++ b/docs/features/naming-templates.md @@ -36,6 +36,7 @@ These tags will be replaced in the template with the audiobook's values. | \ | Audible account of this book | [Text](#text-formatters) | | \ | Audible account nickname of this book | [Text](#text-formatters) | | \ | Tag(s) | [Text List](#text-list-formatters) | +| \ | First tag | [Text](#text-formatters) | | \ | Region/country | [Text](#text-formatters) | | \ | Year published | [Number](#number-formatters) | | \ | Book's language | [Text](#text-formatters) | @@ -178,7 +179,7 @@ For more custom formatters and examples, [see this guide from Microsoft](https:/ | \\ | The escape character. | \ | 2d 14h 42m | These formatters have been enhanced to allow the display of days, hours or months beyond their usual limits. For example, the total number of hours, even if it exceeds 23. -Here, a number format is inserted for the desired part in accordance with [Microsoft’s instructions](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings). Im Unterschied zu den originären Zahlenformaten werden aber anstelle der Nullen die Buchstaben D, H oder M (Großbuchstaben) verwendet. +Here, a number format is inserted for the desired part in accordance with [Microsoft’s instructions](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings). Unlike standard number formats, however, the letters D, H or M (uppercase) are used instead of zeros. | Formatter | Description | Example Usage | Example Result | |-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------|-------------------|