Add additional information to album: record label, release type, version (#1242)

* Add additional information to album

* add mbz release types and normalization

* update Pill styling

---------

Co-authored-by: jeffvli <jeffvictorli@gmail.com>
This commit is contained in:
Kendall Garner
2025-11-03 08:34:42 +00:00
committed by GitHub
parent 3fe6ccf300
commit e26ffaac53
12 changed files with 223 additions and 40 deletions
@@ -218,6 +218,47 @@ const normalizeSong = (
};
};
const parseAlbumTags = (
item: z.infer<typeof ndType._response.album>,
): Pick<Album, 'recordLabels' | 'releaseTypes' | 'tags' | 'version'> => {
if (!item.tags) {
return {
recordLabels: [],
releaseTypes: [],
tags: null,
version: null,
};
}
// We get the genre from elsewhere. We don't need genre twice
delete item.tags['genre'];
let recordLabels: string[] = [];
if (item.tags['recordlabel']) {
recordLabels = item.tags['recordlabel'];
delete item.tags['recordlabel'];
}
let releaseTypes: string[] = [];
if (item.tags['releasetype']) {
releaseTypes = item.tags['releasetype'];
delete item.tags['releasetype'];
}
let version: null | string = null;
if (item.tags['albumversion']) {
version = item.tags['albumversion'].join(' · ');
delete item.tags['albumversion'];
}
return {
recordLabels,
releaseTypes,
tags: item.tags,
version,
};
};
const normalizeAlbum = (
item: z.infer<typeof ndType._response.album> & {
songs?: z.infer<typeof ndType._response.songList>;
@@ -238,8 +279,9 @@ const normalizeAlbum = (
const imageBackdropUrl = imageUrl?.replace(/size=\d+/, 'size=1000') || null;
return {
albumArtist: item.albumArtist,
...parseAlbumTags(item),
...getArtists(item),
albumArtist: item.albumArtist,
backdropImageUrl: imageBackdropUrl,
comment: item.comment || null,
createdAt: item.createdAt.split('T')[0],
@@ -281,7 +323,6 @@ const normalizeAlbum = (
size: item.size,
songCount: item.songCount,
songs: item.songs ? item.songs.map((song) => normalizeSong(song, server)) : undefined,
tags: item.tags || null,
uniqueId: nanoid(),
updatedAt: item.updatedAt,
userFavorite: item.starred,