Increase tag template options for contributor and series types

- Add template tag support for multiple series
- Add series ID and contributor ID to template tags
- <first author> and <first narrator> are now name types with name formatter support
- Properly import contributor IDs into database
- Updated docs
This commit is contained in:
Michael Bucari-Tovo 2025-03-24 15:56:32 -06:00
parent 0a9e489f48
commit 7d806e0f3e
31 changed files with 425 additions and 255 deletions

View file

@ -61,19 +61,19 @@ namespace DtoImporterService
private int upsertPeople(List<Person> people)
{
var hash = people
// new people only
.Where(p => !Cache.ContainsKey(p.Name))
// remove duplicates by Name. first in wins
.ToDictionarySafe(p => p.Name);
foreach (var kvp in hash)
var qtyNew = 0;
foreach (var person in people)
{
var person = kvp.Value;
addContributor(person.Name, person.Asin);
if (!Cache.TryGetValue(person.Name, out var contributor))
{
contributor = createContributor(person.Name, person.Asin);
qtyNew++;
}
updateContributor(person, contributor);
}
return hash.Count;
return qtyNew;
}
// only use after loading contributors => local
@ -86,16 +86,22 @@ namespace DtoImporterService
.ToHashSet();
foreach (var pub in hash)
addContributor(pub);
createContributor(pub);
return hash.Count;
}
private Contributor addContributor(string name, string id = null)
private void updateContributor(Person person, Contributor contributor)
{
if (person.Asin != contributor.AudibleContributorId)
contributor.SetAudibleContributorId(person.Asin);
}
private Contributor createContributor(string name, string id = null)
{
try
{
var newContrib = new Contributor(name);
var newContrib = new Contributor(name, id);
var entityEntry = DbContext.Contributors.Add(newContrib);
var entity = entityEntry.Entity;