add releaseType to album header

This commit is contained in:
jeffvli
2025-12-29 21:16:39 -08:00
parent 145dc5c99e
commit 62ab4b7a00
7 changed files with 111 additions and 3 deletions
@@ -279,6 +279,7 @@ const normalizeAlbum = (
playCount: item.UserData?.PlayCount || 0,
recordLabels: item.Studios?.map((entry) => entry.Name) || [],
releaseDate: item.PremiereDate || null,
releaseType: null,
releaseTypes: [],
releaseYear: item.ProductionYear || null,
size: null,
@@ -304,6 +304,7 @@ const normalizeAlbum = (
originalDate: item.originalDate || null,
playCount: item.playCount || 0,
releaseDate: normalizeReleaseDate(item),
releaseType: item.mbzAlbumType || null,
releaseYear: item.maxYear || null,
size: item.size,
songCount: item.songCount,
@@ -440,6 +440,7 @@ const album = z.object({
allArtistIds: z.string(),
artist: z.string(),
artistId: z.string(),
catalogNum: z.string().optional(),
comment: z.string().optional(),
compilation: z.boolean(),
coverArtId: z.string().optional(), // Removed after v0.48.0
@@ -447,13 +448,21 @@ const album = z.object({
createdAt: z.string(),
duration: z.number().optional(),
explicitStatus: z.string().optional(),
externalInfoUpdatedAt: z.string().optional(),
externalUrl: z.string().optional(),
fullText: z.string(),
genre: z.string(),
genres: z.array(genre).nullable(),
id: z.string(),
importedAt: z.string().optional(),
libraryId: z.number(),
libraryName: z.string(),
libraryPath: z.string(),
maxYear: z.number(),
mbzAlbumArtistId: z.string().optional(),
mbzAlbumId: z.string().optional(),
mbzAlbumType: z.string().optional(),
mbzReleaseGroupId: z.string().optional(),
minYear: z.number(),
name: z.string(),
orderAlbumArtistName: z.string(),
@@ -226,6 +226,19 @@ const normalizeAlbumArtist = (
};
};
const PRIMARY_RELEASE_TYPES = ['album', 'ep', 'single', 'broadcast', 'other'];
const getReleaseType = (
item: z.infer<typeof ssType._response.album> | z.infer<typeof ssType._response.albumListEntry>,
) => {
if (!item.releaseTypes) {
return null;
}
// Return the first primary release type
return item.releaseTypes.find((type) => PRIMARY_RELEASE_TYPES.includes(type)) || null;
};
const normalizeAlbum = (
item: z.infer<typeof ssType._response.album> | z.infer<typeof ssType._response.albumListEntry>,
server?: null | ServerListItemWithCredential,
@@ -269,6 +282,7 @@ const normalizeAlbum = (
item.releaseDate.day,
).toISOString()
: null,
releaseType: getReleaseType(item),
releaseTypes: item.releaseTypes || [],
releaseYear: item.year || null,
size: null,