feat: Support role filters for (album) artist role for Navidrome

- Adds an optional (Navidrome only, currently) field `roles` to type `AlbumArtist`
- `roles` is populated using artist.stats (excludign maincredit)
- `getAlbumList` supports a role filter; if specified, only filter artists with that role (ND only)
- Album list on artist page can filter by role if specified (only one)
- Album query is no longer suspend, as it can change multiple times
This commit is contained in:
Kendall Garner
2026-06-04 21:02:06 -07:00
parent b9312d86fd
commit e7830afc86
9 changed files with 70 additions and 25 deletions
@@ -395,6 +395,7 @@ const normalizeAlbumArtist = (
mbz: item.ProviderIds?.MusicBrainzArtist || null,
name: item.Name,
playCount: item.UserData?.PlayCount || 0,
roles: null,
similarArtists,
songCount: item.SongCount ?? null,
uploadedImage: item.ImageTags?.Primary ?? undefined,
@@ -410,10 +410,12 @@ const normalizeAlbumArtist = (
if (item.stats) {
albumCount = Math.max(
item.stats.maincredit?.albumCount ?? 0,
item.stats.albumartist?.albumCount ?? 0,
item.stats.artist?.albumCount ?? 0,
);
songCount = Math.max(
item.stats.maincredit?.songCount ?? 0,
item.stats.albumartist?.songCount ?? 0,
item.stats.artist?.songCount ?? 0,
);
@@ -453,6 +455,8 @@ const normalizeAlbumArtist = (
mbz: item.mbzArtistId || null,
name: item.name,
playCount: item.playCount || 0,
// filter out specifically maincredit. This is not filterable properly
roles: item.stats ? Object.keys(item.stats).filter((key) => key !== 'maincredit') : null,
similarArtists:
item.similarArtists?.map((artist) => ({
id: artist.id,
@@ -274,6 +274,7 @@ const normalizeAlbumArtist = (
mbz: null,
name: item.name,
playCount: null,
roles: null,
similarArtists:
item.similarArtists?.map((artist) => ({
id: artist.id,
+2
View File
@@ -223,6 +223,7 @@ export type AlbumArtist = {
mbz: null | string;
name: string;
playCount: null | number;
roles: null | string[];
similarArtists: null | RelatedArtist[];
songCount: null | number;
uploadedImage?: string;
@@ -500,6 +501,7 @@ export interface AlbumListQuery extends AlbumListNavidromeQuery, BaseQuery<Album
maxYear?: number;
minYear?: number;
musicFolderId?: string | string[];
role?: string;
searchTerm?: string;
startIndex: number;
}