Add <account nickname> tag (#629)
This commit is contained in:
parent
7a9c6720c7
commit
6d13325c4f
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AudibleUtilities;
|
||||||
using DataLayer;
|
using DataLayer;
|
||||||
using Dinah.Core;
|
using Dinah.Core;
|
||||||
using LibationFileManager;
|
using LibationFileManager;
|
||||||
@ -20,34 +21,44 @@ namespace FileLiberator
|
|||||||
|
|
||||||
public static async Task<AudibleApi.Api> GetApiAsync(this LibraryBook libraryBook)
|
public static async Task<AudibleApi.Api> GetApiAsync(this LibraryBook libraryBook)
|
||||||
{
|
{
|
||||||
var apiExtended = await AudibleUtilities.ApiExtended.CreateAsync(libraryBook.Account, libraryBook.Book.Locale);
|
var apiExtended = await ApiExtended.CreateAsync(libraryBook.Account, libraryBook.Book.Locale);
|
||||||
return apiExtended.Api;
|
return apiExtended.Api;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LibraryBookDto ToDto(this LibraryBook libraryBook) => new()
|
public static LibraryBookDto ToDto(this LibraryBook libraryBook)
|
||||||
{
|
{
|
||||||
Account = libraryBook.Account,
|
using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
|
||||||
DateAdded = libraryBook.DateAdded,
|
var nickname
|
||||||
|
= persister.AccountsSettings.Accounts
|
||||||
|
.FirstOrDefault(a => a.AccountId == libraryBook.Account)
|
||||||
|
?.AccountName;
|
||||||
|
|
||||||
AudibleProductId = libraryBook.Book.AudibleProductId,
|
return new()
|
||||||
Title = libraryBook.Book.Title ?? "",
|
{
|
||||||
Locale = libraryBook.Book.Locale,
|
Account = libraryBook.Account,
|
||||||
YearPublished = libraryBook.Book.DatePublished?.Year,
|
AccountNickname = nickname,
|
||||||
DatePublished = libraryBook.Book.DatePublished,
|
DateAdded = libraryBook.DateAdded,
|
||||||
|
|
||||||
Authors = libraryBook.Book.Authors.Select(c => c.Name).ToList(),
|
AudibleProductId = libraryBook.Book.AudibleProductId,
|
||||||
|
Title = libraryBook.Book.Title ?? "",
|
||||||
|
Locale = libraryBook.Book.Locale,
|
||||||
|
YearPublished = libraryBook.Book.DatePublished?.Year,
|
||||||
|
DatePublished = libraryBook.Book.DatePublished,
|
||||||
|
|
||||||
Narrators = libraryBook.Book.Narrators.Select(c => c.Name).ToList(),
|
Authors = libraryBook.Book.Authors.Select(c => c.Name).ToList(),
|
||||||
|
|
||||||
SeriesName = libraryBook.Book.SeriesLink.FirstOrDefault()?.Series.Name,
|
Narrators = libraryBook.Book.Narrators.Select(c => c.Name).ToList(),
|
||||||
SeriesNumber = (int?)libraryBook.Book.SeriesLink.FirstOrDefault()?.Index,
|
|
||||||
IsPodcastParent = libraryBook.Book.IsEpisodeParent(),
|
|
||||||
IsPodcast = libraryBook.Book.IsEpisodeChild() || libraryBook.Book.IsEpisodeParent(),
|
|
||||||
|
|
||||||
BitRate = libraryBook.Book.AudioFormat.Bitrate,
|
SeriesName = libraryBook.Book.SeriesLink.FirstOrDefault()?.Series.Name,
|
||||||
SampleRate = libraryBook.Book.AudioFormat.SampleRate,
|
SeriesNumber = (int?)libraryBook.Book.SeriesLink.FirstOrDefault()?.Index,
|
||||||
Channels = libraryBook.Book.AudioFormat.Channels,
|
IsPodcastParent = libraryBook.Book.IsEpisodeParent(),
|
||||||
Language = libraryBook.Book.Language
|
IsPodcast = libraryBook.Book.IsEpisodeChild() || libraryBook.Book.IsEpisodeParent(),
|
||||||
};
|
|
||||||
|
BitRate = libraryBook.Book.AudioFormat.Bitrate,
|
||||||
|
SampleRate = libraryBook.Book.AudioFormat.SampleRate,
|
||||||
|
Channels = libraryBook.Book.AudioFormat.Channels,
|
||||||
|
Language = libraryBook.Book.Language
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,5 +37,6 @@ namespace LibationFileManager
|
|||||||
{
|
{
|
||||||
public DateTime? DateAdded { get; set; }
|
public DateTime? DateAdded { get; set; }
|
||||||
public string Account { get; set; }
|
public string Account { get; set; }
|
||||||
|
public string AccountNickname { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,7 +52,8 @@ namespace LibationFileManager
|
|||||||
private static readonly LibraryBookDto libraryBookDto
|
private static readonly LibraryBookDto libraryBookDto
|
||||||
= new()
|
= new()
|
||||||
{
|
{
|
||||||
Account = "my account",
|
Account = "myaccount@example.co",
|
||||||
|
AccountNickname = "my account",
|
||||||
DateAdded = new DateTime(2022, 6, 9, 0, 0, 0),
|
DateAdded = new DateTime(2022, 6, 9, 0, 0, 0),
|
||||||
DatePublished = new DateTime(2017, 2, 27, 0, 0, 0),
|
DatePublished = new DateTime(2017, 2, 27, 0, 0, 0),
|
||||||
AudibleProductId = "123456789",
|
AudibleProductId = "123456789",
|
||||||
|
|||||||
@ -37,6 +37,7 @@ namespace LibationFileManager
|
|||||||
public static TemplateTags SampleRate { get; } = new TemplateTags("samplerate", "File's orig. sample rate");
|
public static TemplateTags SampleRate { get; } = new TemplateTags("samplerate", "File's orig. sample rate");
|
||||||
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 AccountNickname { get; } = new TemplateTags("account nickname", "Audible account nickname of this book");
|
||||||
public static TemplateTags Locale { get; } = new ("locale", "Region/country");
|
public static TemplateTags Locale { get; } = new ("locale", "Region/country");
|
||||||
public static TemplateTags YearPublished { get; } = new("year", "Year published");
|
public static TemplateTags YearPublished { get; } = new("year", "Year published");
|
||||||
public static TemplateTags Language { get; } = new("language", "Book's language");
|
public static TemplateTags Language { get; } = new("language", "Book's language");
|
||||||
|
|||||||
@ -215,6 +215,7 @@ namespace LibationFileManager
|
|||||||
{ TemplateTags.SampleRate, lb => (int?)(lb.IsPodcastParent ? null : lb.SampleRate) },
|
{ TemplateTags.SampleRate, lb => (int?)(lb.IsPodcastParent ? null : lb.SampleRate) },
|
||||||
{ TemplateTags.Channels, lb => (int?)(lb.IsPodcastParent ? null : lb.Channels) },
|
{ TemplateTags.Channels, lb => (int?)(lb.IsPodcastParent ? null : lb.Channels) },
|
||||||
{ TemplateTags.Account, lb => lb.Account },
|
{ TemplateTags.Account, lb => lb.Account },
|
||||||
|
{ TemplateTags.AccountNickname, lb => lb.AccountNickname },
|
||||||
{ TemplateTags.Locale, lb => lb.Locale },
|
{ TemplateTags.Locale, lb => lb.Locale },
|
||||||
{ TemplateTags.YearPublished, lb => lb.YearPublished },
|
{ TemplateTags.YearPublished, lb => lb.YearPublished },
|
||||||
{ TemplateTags.DatePublished, lb => lb.DatePublished },
|
{ TemplateTags.DatePublished, lb => lb.DatePublished },
|
||||||
|
|||||||
@ -26,7 +26,8 @@ namespace TemplatesTests
|
|||||||
public static LibraryBookDto GetLibraryBook(string seriesName = "Sherlock Holmes")
|
public static LibraryBookDto GetLibraryBook(string seriesName = "Sherlock Holmes")
|
||||||
=> new()
|
=> new()
|
||||||
{
|
{
|
||||||
Account = "my account",
|
Account = "myaccount@example.co",
|
||||||
|
AccountNickname = "my account",
|
||||||
DateAdded = new DateTime(2022, 6, 9, 0, 0, 0),
|
DateAdded = new DateTime(2022, 6, 9, 0, 0, 0),
|
||||||
DatePublished = new DateTime(2017, 2, 27, 0, 0, 0),
|
DatePublished = new DateTime(2017, 2, 27, 0, 0, 0),
|
||||||
FileDate = new DateTime(2023, 1, 28, 0, 0, 0),
|
FileDate = new DateTime(2023, 1, 28, 0, 0, 0),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user