#367 : New template option "year": year published to audible

This commit is contained in:
Robert McRackan 2022-10-21 13:41:44 -04:00
parent 99564d9c25
commit d64e043fe8
8 changed files with 13 additions and 5 deletions

View File

@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Version>8.4.6.1</Version> <Version>8.5.0.1</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Octokit" Version="4.0.0" /> <PackageReference Include="Octokit" Version="4.0.0" />

View File

@ -31,6 +31,7 @@ namespace FileLiberator
AudibleProductId = libraryBook.Book.AudibleProductId, AudibleProductId = libraryBook.Book.AudibleProductId,
Title = libraryBook.Book.Title ?? "", Title = libraryBook.Book.Title ?? "",
Locale = libraryBook.Book.Locale, Locale = libraryBook.Book.Locale,
YearPublished = libraryBook.Book.DatePublished?.Year,
Authors = libraryBook.Book.Authors.Select(c => c.Name).ToList(), Authors = libraryBook.Book.Authors.Select(c => c.Name).ToList(),

View File

@ -138,6 +138,7 @@ namespace LibationAvalonia.Dialogs
AudibleProductId = "123456789", AudibleProductId = "123456789",
Title = "A Study in Scarlet: A Sherlock Holmes Novel", Title = "A Study in Scarlet: A Sherlock Holmes Novel",
Locale = "us", Locale = "us",
YearPublished = 2017,
Authors = new List<string> { "Arthur Conan Doyle", "Stephen Fry - introductions" }, Authors = new List<string> { "Arthur Conan Doyle", "Stephen Fry - introductions" },
Narrators = new List<string> { "Stephen Fry" }, Narrators = new List<string> { "Stephen Fry" },
SeriesName = "Sherlock Holmes", SeriesName = "Sherlock Holmes",

View File

@ -9,6 +9,7 @@ namespace LibationFileManager
public string AudibleProductId { get; set; } public string AudibleProductId { get; set; }
public string Title { get; set; } public string Title { get; set; }
public string Locale { get; set; } public string Locale { get; set; }
public int? YearPublished { get; set; }
public IEnumerable<string> Authors { get; set; } public IEnumerable<string> Authors { get; set; }
public string AuthorNames => string.Join(", ", Authors); public string AuthorNames => string.Join(", ", Authors);

View File

@ -39,6 +39,7 @@ namespace LibationFileManager
public static TemplateTags Channels { get; } = new TemplateTags("channels", "Number of audio channels"); public static TemplateTags Channels { get; } = new TemplateTags("channels", "Number of audio channels");
public static TemplateTags Account { get; } = new TemplateTags("account", "Audible account of this book"); public static TemplateTags Account { get; } = new TemplateTags("account", "Audible account of this book");
public static TemplateTags Locale { get; } = new TemplateTags("locale", "Region/country"); public static TemplateTags Locale { get; } = new TemplateTags("locale", "Region/country");
public static TemplateTags YearPublished { get; } = new TemplateTags("year", "Year published");
// Special case. Isn't mapped to a replacement in Templates.cs // Special case. Isn't mapped to a replacement in Templates.cs
// Included here for display by EditTemplateDialog // Included here for display by EditTemplateDialog

View File

@ -142,8 +142,9 @@ namespace LibationFileManager
fileNamingTemplate.AddParameterReplacement(TemplateTags.Channels, libraryBookDto.Channels); fileNamingTemplate.AddParameterReplacement(TemplateTags.Channels, libraryBookDto.Channels);
fileNamingTemplate.AddParameterReplacement(TemplateTags.Account, libraryBookDto.Account); fileNamingTemplate.AddParameterReplacement(TemplateTags.Account, libraryBookDto.Account);
fileNamingTemplate.AddParameterReplacement(TemplateTags.Locale, libraryBookDto.Locale); fileNamingTemplate.AddParameterReplacement(TemplateTags.Locale, libraryBookDto.Locale);
fileNamingTemplate.AddParameterReplacement(TemplateTags.YearPublished, libraryBookDto.YearPublished?.ToString() ?? "1900");
return fileNamingTemplate; return fileNamingTemplate;
} }
#endregion #endregion

View File

@ -76,7 +76,8 @@ namespace LibationWinForms.Dialogs
AudibleProductId = "123456789", AudibleProductId = "123456789",
Title = "A Study in Scarlet: A Sherlock Holmes Novel", Title = "A Study in Scarlet: A Sherlock Holmes Novel",
Locale = "us", Locale = "us",
Authors = new List<string> { "Arthur Conan Doyle", "Stephen Fry - introductions" }, YearPublished = 2017,
Authors = new List<string> { "Arthur Conan Doyle", "Stephen Fry - introductions" },
Narrators = new List<string> { "Stephen Fry" }, Narrators = new List<string> { "Stephen Fry" },
SeriesName = "Sherlock Holmes", SeriesName = "Sherlock Holmes",
SeriesNumber = "1", SeriesNumber = "1",

View File

@ -29,7 +29,8 @@ namespace TemplatesTests
AudibleProductId = "asin", AudibleProductId = "asin",
Title = "A Study in Scarlet: A Sherlock Holmes Novel", Title = "A Study in Scarlet: A Sherlock Holmes Novel",
Locale = "us", Locale = "us",
Authors = new List<string> { "Arthur Conan Doyle", "Stephen Fry - introductions" }, YearPublished = 2017,
Authors = new List<string> { "Arthur Conan Doyle", "Stephen Fry - introductions" },
Narrators = new List<string> { "Stephen Fry" }, Narrators = new List<string> { "Stephen Fry" },
SeriesName = seriesName ?? "", SeriesName = seriesName ?? "",
SeriesNumber = "1", SeriesNumber = "1",
@ -87,7 +88,8 @@ namespace TemplatesTests
[DataRow("f", @"C:\foo\bar", "ext", @"C:\foo\bar\f.ext")] [DataRow("f", @"C:\foo\bar", "ext", @"C:\foo\bar\f.ext")]
[DataRow("<id>", @"C:\foo\bar", "ext", @"C:\foo\bar\asin.ext")] [DataRow("<id>", @"C:\foo\bar", "ext", @"C:\foo\bar\asin.ext")]
[DataRow("<bitrate> - <samplerate> - <channels>", @"C:\foo\bar", "ext", @"C:\foo\bar\128 - 44100 - 2.ext")] [DataRow("<bitrate> - <samplerate> - <channels>", @"C:\foo\bar", "ext", @"C:\foo\bar\128 - 44100 - 2.ext")]
public void Tests(string template, string dirFullPath, string extension, string expected) [DataRow("<year> - <channels>", @"C:\foo\bar", "ext", @"C:\foo\bar\2017 - 2.ext")]
public void Tests(string template, string dirFullPath, string extension, string expected)
=> Templates.getFileNamingTemplate(GetLibraryBook(), template, dirFullPath, extension) => Templates.getFileNamingTemplate(GetLibraryBook(), template, dirFullPath, extension)
.GetFilePath(Replacements) .GetFilePath(Replacements)
.PathWithoutPrefix .PathWithoutPrefix