Merge pull request #633 from Mbucari/master
User series order float (#632)
This commit is contained in:
commit
6765c2bfa7
@ -11,7 +11,7 @@ These templates apply to both GUI and CLI.
|
|||||||
- [Tag Formatters](#tag-formatters)
|
- [Tag Formatters](#tag-formatters)
|
||||||
- [Text Formatters](#text-formatters)
|
- [Text Formatters](#text-formatters)
|
||||||
- [Name List Formatters](#name-list-formatters)
|
- [Name List Formatters](#name-list-formatters)
|
||||||
- [Integer Formatters](#integer-formatters)
|
- [Number Formatters](#number-formatters)
|
||||||
- [Date Formatters](#date-formatters)
|
- [Date Formatters](#date-formatters)
|
||||||
|
|
||||||
|
|
||||||
@ -32,23 +32,23 @@ These tags will be replaced in the template with the audiobook's values.
|
|||||||
|\<narrator\>|Narrator(s)|Name List|
|
|\<narrator\>|Narrator(s)|Name List|
|
||||||
|\<first narrator\>|First narrator|Text|
|
|\<first narrator\>|First narrator|Text|
|
||||||
|\<series\>|Name of series|Text|
|
|\<series\>|Name of series|Text|
|
||||||
|\<series#\>|Number order in series|Text|
|
|\<series#\>|Number order in series|Number|
|
||||||
|\<bitrate\>|File's original bitrate (Kbps)|Integer|
|
|\<bitrate\>|File's original bitrate (Kbps)|Number|
|
||||||
|\<samplerate\>|File's original audio sample rate|Integer|
|
|\<samplerate\>|File's original audio sample rate|Number|
|
||||||
|\<channels\>|Number of audio channels|Integer|
|
|\<channels\>|Number of audio channels|Number|
|
||||||
|\<account\>|Audible account of this book|Text|
|
|\<account\>|Audible account of this book|Text|
|
||||||
|\<account nickname\>|Audible account nickname of this book|Text|
|
|\<account nickname\>|Audible account nickname of this book|Text|
|
||||||
|\<locale\>|Region/country|Text|
|
|\<locale\>|Region/country|Text|
|
||||||
|\<year\>|Year published|Integer|
|
|\<year\>|Year published|Number|
|
||||||
|\<language\>|Book's language|Text|
|
|\<language\>|Book's language|Text|
|
||||||
|\<language short\> **†**|Book's language abbreviated. Eg: ENG|Text|
|
|\<language short\> **†**|Book's language abbreviated. Eg: ENG|Text|
|
||||||
|\<file date\>|File creation date/time.|DateTime|
|
|\<file date\>|File creation date/time.|DateTime|
|
||||||
|\<pub date\>|Audiobook publication date|DateTime|
|
|\<pub date\>|Audiobook publication date|DateTime|
|
||||||
|\<date added\>|Date the book added to your Audible account|DateTime|
|
|\<date added\>|Date the book added to your Audible account|DateTime|
|
||||||
|\<ch count\> **‡**|Number of chapters|Integer|
|
|\<ch count\> **‡**|Number of chapters|Number|
|
||||||
|\<ch title\> **‡**|Chapter title|Text|
|
|\<ch title\> **‡**|Chapter title|Text|
|
||||||
|\<ch#\> **‡**|Chapter number|Integer|
|
|\<ch#\> **‡**|Chapter number|Number|
|
||||||
|\<ch# 0\> **‡**|Chapter number with leading zeros|Integer|
|
|\<ch# 0\> **‡**|Chapter number with leading zeros|Number|
|
||||||
|
|
||||||
**†** Does not support custom formatting
|
**†** Does not support custom formatting
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ As an example, this folder template will place all Liberated podcasts into a "Po
|
|||||||
|
|
||||||
|
|
||||||
# Tag Formatters
|
# Tag Formatters
|
||||||
**Text**, **Name List**, **Integer**, and **DateTime** tags can be optionally formatted using format text in square brackets after the tag name. Below is a list of supported formatters for each tag type.
|
**Text**, **Name List**, **Number**, and **DateTime** tags can be optionally formatted using format text in square brackets after the tag name. Below is a list of supported formatters for each tag type.
|
||||||
|
|
||||||
## Text Formatters
|
## Text Formatters
|
||||||
|Formatter|Description|Example Usage|Example Result|
|
|Formatter|Description|Example Usage|Example Result|
|
||||||
@ -89,15 +89,18 @@ As an example, this folder template will place all Liberated podcasts into a "Po
|
|||||||
## Name List Formatters
|
## Name List Formatters
|
||||||
|Formatter|Description|Example Usage|Example Result|
|
|Formatter|Description|Example Usage|Example Result|
|
||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
|separator()|Speficy the text used to join multiple people's names.<br><br>Default is ", "|`<author[separator(; )]>`|Arthur Conan Doyle; Stephen Fry|
|
|separator()|Speficy the text used to join<br>multiple people's names.<br><br>Default is ", "|`<author[separator(; )]>`|Arthur Conan Doyle; Stephen Fry|
|
||||||
|format(\{T \| F \| M \| L \| S\})|Formats the human name using the name part tags.<br>\{T\} = Title (e.g. "Dr.")<br>\{F\} = First name<br>\{M\} = Middle name<br>\{L\} = Last Name<br>\{S\} = Suffix (e.g. "PhD")<br><br>Default is \{P\} \{F\} \{M\} \{L\} \{S\} |`<author[format({L}, {F}) separator(; )]>`|Doyle, Arthur; Fry, Stephen|
|
|format(\{T \| F \| M \| L \| S\})|Formats the human name using<br>the name part tags.<br>\{T\} = Title (e.g. "Dr.")<br>\{F\} = First name<br>\{M\} = Middle name<br>\{L\} = Last Name<br>\{S\} = Suffix (e.g. "PhD")<br><br>Default is \{P\} \{F\} \{M\} \{L\} \{S\}|`<author[format({L}, {F})`<br>`separator(; )]>`|Doyle, Arthur; Fry, Stephen|
|
||||||
|sort(F \| M \| L)|Sorts the names by first, middle, or last name<br><br>Default is unsorted|`<author[sort(M)]>`|Stephen Fry, Arthur Conan Doyle|
|
|sort(F \| M \| L)|Sorts the names by first, middle,<br>or last name<br><br>Default is unsorted|`<author[sort(M)]>`|Stephen Fry, Arthur Conan Doyle|
|
||||||
|max(#)|Only use the first # of names<br><br>Default is all names|`<author[max(1)]>`|Arthur Conan Doyle|
|
|max(#)|Only use the first # of names<br><br>Default is all names|`<author[max(1)]>`|Arthur Conan Doyle|
|
||||||
|
|
||||||
## Integer Formatters
|
## Number Formatters
|
||||||
|
For more custom formatters and examples, [see this guide from Microsoft](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings).
|
||||||
|Formatter|Description|Example Usage|Example Result|
|
|Formatter|Description|Example Usage|Example Result|
|
||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
|# (a number)|Zero-pads the number|\<bitrate\[4\]\><br>\<series#\[3\]\><br>\<samplerate\[6\]\>|0128<br>001<br>044100|
|
|\[integer\]|Zero-pads the number|\<bitrate\[4\]\><br>\<series#\[3\]\><br>\<samplerate\[6\]\>|0128<br>001<br>044100|
|
||||||
|
|0|Replaces the zero with the corresponding digit if one<br>is present; otherwise, zero appears in the result string.|\<series#\[000.0\]\>|001.0|
|
||||||
|
|#|Replaces the "#" symbol with the corresponding digit if one<br> is present; otherwise, no digit appears in the result string|\<series#\[00.##\]\>|01|
|
||||||
|
|
||||||
## Date Formatters
|
## Date Formatters
|
||||||
Form more standard formatters, [see this guide from Microsoft](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings).
|
Form more standard formatters, [see this guide from Microsoft](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings).
|
||||||
|
|||||||
@ -50,7 +50,7 @@ namespace FileLiberator
|
|||||||
Narrators = libraryBook.Book.Narrators.Select(c => c.Name).ToList(),
|
Narrators = libraryBook.Book.Narrators.Select(c => c.Name).ToList(),
|
||||||
|
|
||||||
SeriesName = libraryBook.Book.SeriesLink.FirstOrDefault()?.Series.Name,
|
SeriesName = libraryBook.Book.SeriesLink.FirstOrDefault()?.Series.Name,
|
||||||
SeriesNumber = (int?)libraryBook.Book.SeriesLink.FirstOrDefault()?.Index,
|
SeriesNumber = libraryBook.Book.SeriesLink.FirstOrDefault()?.Index,
|
||||||
IsPodcastParent = libraryBook.Book.IsEpisodeParent(),
|
IsPodcastParent = libraryBook.Book.IsEpisodeParent(),
|
||||||
IsPodcast = libraryBook.Book.IsEpisodeChild() || libraryBook.Book.IsEpisodeParent(),
|
IsPodcast = libraryBook.Book.IsEpisodeChild() || libraryBook.Book.IsEpisodeParent(),
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ namespace LibationFileManager
|
|||||||
public string FirstNarrator => Narrators.FirstOrDefault();
|
public string FirstNarrator => Narrators.FirstOrDefault();
|
||||||
|
|
||||||
public string SeriesName { get; set; }
|
public string SeriesName { get; set; }
|
||||||
public int? SeriesNumber { get; set; }
|
public float? SeriesNumber { get; set; }
|
||||||
public bool IsSeries => !string.IsNullOrEmpty(SeriesName);
|
public bool IsSeries => !string.IsNullOrEmpty(SeriesName);
|
||||||
public bool IsPodcastParent { get; set; }
|
public bool IsPodcastParent { get; set; }
|
||||||
public bool IsPodcast { get; set; }
|
public bool IsPodcast { get; set; }
|
||||||
|
|||||||
@ -196,7 +196,7 @@ namespace LibationFileManager
|
|||||||
#region Registered Template Properties
|
#region Registered Template Properties
|
||||||
|
|
||||||
private static readonly PropertyTagCollection<LibraryBookDto> filePropertyTags =
|
private static readonly PropertyTagCollection<LibraryBookDto> filePropertyTags =
|
||||||
new(caseSensative: true, StringFormatter, DateTimeFormatter, IntegerFormatter)
|
new(caseSensative: true, StringFormatter, DateTimeFormatter, IntegerFormatter, FloatFormatter)
|
||||||
{
|
{
|
||||||
//Don't allow formatting of Id
|
//Don't allow formatting of Id
|
||||||
{ TemplateTags.Id, lb => lb.AudibleProductId, v => v },
|
{ TemplateTags.Id, lb => lb.AudibleProductId, v => v },
|
||||||
@ -279,10 +279,20 @@ namespace LibationFileManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static string IntegerFormatter(ITemplateTag templateTag, int value, string formatString)
|
private static string IntegerFormatter(ITemplateTag templateTag, int value, string formatString)
|
||||||
|
=> FloatFormatter(templateTag, value, formatString);
|
||||||
|
|
||||||
|
private static string FloatFormatter(ITemplateTag templateTag, float value, string formatString)
|
||||||
{
|
{
|
||||||
if (int.TryParse(formatString, out var numDigits))
|
if (int.TryParse(formatString, out var numDigits) && numDigits > 0)
|
||||||
return value.ToString($"D{numDigits}");
|
{
|
||||||
return value.ToString();
|
//Zero-pad the integer part
|
||||||
|
var strValue = value.ToString();
|
||||||
|
var decIndex = strValue.IndexOf(System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator);
|
||||||
|
var zeroPad = decIndex == -1 ? int.Max(0, numDigits - strValue.Length) : int.Max(0, numDigits - decIndex);
|
||||||
|
|
||||||
|
return new string('0', zeroPad) + strValue;
|
||||||
|
}
|
||||||
|
return value.ToString(formatString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string DateTimeFormatter(ITemplateTag templateTag, DateTime value, string formatString)
|
private static string DateTimeFormatter(ITemplateTag templateTag, DateTime value, string formatString)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user