tag/Fallback: add tag fallbacks for AlbumArtistSort, ArtistSort

Just like AlbumArtist falls back to Artist, AlbumArtistSort should
fall back tom AlbumArtist, ArtistSort and finally Artist.

Closes #355
This commit is contained in:
Max Kellermann 2018-10-22 10:52:42 +02:00
parent 21adc78713
commit 53448e4633
2 changed files with 14 additions and 2 deletions

2
NEWS
View File

@ -1,4 +1,6 @@
ver 0.20.22 (not yet released)
* protocol
- add tag fallbacks for AlbumArtistSort, ArtistSort
* storage
- curl: URL-encode paths
* Android

View File

@ -26,8 +26,18 @@ template<typename F>
bool
ApplyTagFallback(TagType type, F &&f) noexcept
{
if (type == TAG_ALBUM_ARTIST)
/* fall back to "Artist" if no "AlbumArtist" was found */
if (type == TAG_ALBUM_ARTIST_SORT) {
/* fall back to "AlbumArtist", "ArtistSort" and
"Artist" if no "AlbumArtistSort" was found */
if (f(TAG_ALBUM_ARTIST))
return true;
return ApplyTagFallback(TAG_ARTIST_SORT, std::forward<F>(f));
}
if (type == TAG_ALBUM_ARTIST || type == TAG_ARTIST_SORT)
/* fall back to "Artist" if no
"AlbumArtist"/"ArtistSort" was found */
return f(TAG_ARTIST);
return false;