Audible via API to prevent use of empty fields when composing fields

Lovely. Another thing I noticed that might be unwanted is that when there is a Series, but no Series-Part, CONTENTGROUP and ALBUMSORT get formatted as if there was a Series-Part.

Example: Weihnachten auf der Lindwurmfeste by Walter Moers
ASIN: 3844530843 looked up on .com yields:

ALBUMSORT:
Zamonien - Weihnachten auf der Lindwurmfeste
1 superflous space after the series name.

CONTENTGROUP:
Zamonien, Book #
, Book # is not needed without a series number imho.

That is a pity.

Good to know, thank you for looking into it!

I agree, there would always be outliers that yield wrong results.

Since I only started treating audiobooks separately a bit over a week ago when I set up audiobookshelf, I was using a fairly primitve regex that works for single authors but instantly breaks when there's more than one since I was hoping that the Audible API yields the required information.

Now that you told me that it does not, I tried to refine my regex to account for single and multiple authors, but I've hit a snag.

This regex works well for 2 or more authors (I decided to truncate more than 2 authors down to 2 for the sorting field to avoid too long folder names), but leaves extra ; , when there's only one author.
I had hoped to use [] to only add those parts when the last1 and first1 capturing groups are not empty, but it seems that named capturing groups do not count as placeholders.

Test without [] yields both authors.

$regexp(%albumartist%,^(?<first>'['^','']'+) (?<last>'['^','']'+)(?:(?:',' )(?<first1>'['^','']'+) (?<last1>'['^','']'+))?.*$,$+{last}',' $+{first}; $+{last1}',' $+{first1})


Test with [] only yields the first author.

$regexp(%albumartist%,^(?<first>'['^','']'+) (?<last>'['^','']'+)(?:(?:',' )(?<first1>'['^','']'+) (?<last1>'['^','']'+))?.*$,$+{last}',' $+{first}[; $+{last1}',' $+{first1}])

Personally I'll work around this limitation by using a secondary action to clean up. Here is the current state of what I'm using to fill ALBUMARTISTSORT based on ALBUMARTIST.

Action 1: Format value
Field: ALBUMARTISTSORT
Format String:

$if2(%albumartistsort%,$regexp(%albumartist%,^(?<first>'['^','']'+) (?<last>'['^','']'+)(?:(?:',' )(?<first1>'['^','']'+) (?<last1>'['^','']'+))?.*$,$+{last}',' $+{first}; $+{last1}',' $+{first1}))

This doesn't change existing ALBUMARTISTSORT fields and tries to swap first name and last name of the first 2 authors in ALBUMARTIST, separated by ; .

Action 2: Replace with regular expression
Regular expression: ^(.+); , $
Replace matches with: $1

This cleans up ; , when there was only a single author.

However since I have so far only added 55 authors, these actions are not widely tested and should only be used if the user understands them and their limitations. I'm sure that there are author names that break them or yield nonsensical results. I'll try to account for them as I encounter them.