navidrome cover art workaround

This commit is contained in:
Kendall Garner 2025-05-15 19:10:15 -07:00
parent a8fb7ff11e
commit 39c714a137
No known key found for this signature in database
GPG key ID: 9355F387FE765C94
8 changed files with 110 additions and 8 deletions

View file

@ -117,6 +117,9 @@ export const controller: GeneralController = {
getMusicFolderList(args) {
return apiController('getMusicFolderList', args.apiClientProps.server?.type)?.(args);
},
getAlbumInfo(args) {
return apiController('getAlbumInfo', args.apiClientProps.server?.type)?.(args);
},
getPlaylistDetail(args) {
return apiController('getPlaylistDetail', args.apiClientProps.server?.type)?.(args);
},

View file

@ -242,6 +242,26 @@ export const NavidromeController: ControllerEndpoint = {
apiClientProps.server,
);
},
getAlbumInfo: async (args) => {
const { query, apiClientProps } = args;
const albumInfo = await ssApiClient(apiClientProps).getAlbumInfo2({
query: {
id: query.id,
},
});
if (albumInfo.status !== 200) {
throw new Error('Failed to get album info');
}
const info = albumInfo.body.albumInfo;
return {
imageUrl: info.largeImageUrl || info.mediumImageUrl || info.smallImageUrl || null,
notes: info.notes || null,
};
},
getAlbumList: async (args) => {
const { query, apiClientProps } = args;

View file

@ -51,6 +51,14 @@ export const contract = c.router({
200: ssType._response.getAlbum,
},
},
getAlbumInfo2: {
method: 'GET',
path: 'getAlbumInfo2.view',
query: ssType._parameters.albumInfo,
responses: {
200: ssType._response.albumInfo,
},
},
getAlbumList2: {
method: 'GET',
path: 'getAlbumList2.view',

View file

@ -522,8 +522,24 @@ const getAlbumList2 = z.object({
}),
});
const albumInfoParameters = z.object({
id: z.string(),
});
const albumInfo = z.object({
albumInfo: z.object({
largeImageUrl: z.string().optional(),
lastFmUrl: z.string().optional(),
mediumImageUrl: z.string().optional(),
musicBrainzId: z.string().optional(),
notes: z.string().optional(),
smallImageUrl: z.string().optional(),
}),
});
export const ssType = {
_parameters: {
albumInfo: albumInfoParameters,
albumList: albumListParameters,
artistInfo: artistInfoParameters,
authenticate: authenticateParameters,
@ -555,6 +571,7 @@ export const ssType = {
album,
albumArtist,
albumArtistList,
albumInfo,
albumList,
albumListEntry,
artistInfo,

View file

@ -465,6 +465,11 @@ export type AlbumDetailQuery = { id: string };
export type AlbumDetailArgs = { query: AlbumDetailQuery } & BaseEndpointArgs;
export type AlbumInfo = {
imageUrl: string | null;
notes: string | null;
};
// Song List
export type SongListResponse = BasePaginatedResponse<Song[]> | null | undefined;
@ -1246,6 +1251,7 @@ export type ControllerEndpoint = {
getAlbumArtistList: (args: AlbumArtistListArgs) => Promise<AlbumArtistListResponse>;
getAlbumArtistListCount: (args: AlbumArtistListArgs) => Promise<number>;
getAlbumDetail: (args: AlbumDetailArgs) => Promise<AlbumDetailResponse>;
getAlbumInfo?: (args: AlbumDetailArgs) => Promise<AlbumInfo>;
getAlbumList: (args: AlbumListArgs) => Promise<AlbumListResponse>;
getAlbumListCount: (args: AlbumListArgs) => Promise<number>;
// getArtistInfo?: (args: any) => void;