Re-add artistInfo api call for navidrome

This commit is contained in:
jeffvli 2023-05-20 02:24:40 -07:00
parent 645b4fe332
commit c854fd0a5b
3 changed files with 29 additions and 11 deletions

View file

@ -42,6 +42,7 @@ import {
import { ndApiClient } from '/@/renderer/api/navidrome/navidrome-api';
import { ndNormalize } from '/@/renderer/api/navidrome/navidrome-normalize';
import { ndType } from '/@/renderer/api/navidrome/navidrome-types';
import { ssApiClient } from '/@/renderer/api/subsonic/subsonic-api';
const authenticate = async (
url: string,
@ -119,6 +120,13 @@ const getAlbumArtistDetail = async (
},
});
const artistInfoRes = await ssApiClient(apiClientProps).getArtistInfo({
query: {
count: 10,
id: query.id,
},
});
if (res.status !== 200) {
throw new Error('Failed to get album artist detail');
}
@ -127,7 +135,15 @@ const getAlbumArtistDetail = async (
throw new Error('Server is required');
}
return ndNormalize.albumArtist(res.body.data, apiClientProps.server);
return ndNormalize.albumArtist(
{
...res.body.data,
...(artistInfoRes.status === 200 && {
similarArtists: artistInfoRes.body.artistInfo.similarArtist,
}),
},
apiClientProps.server,
);
};
const getAlbumArtistList = async (args: AlbumArtistListArgs): Promise<AlbumArtistListResponse> => {

View file

@ -1,8 +1,9 @@
import { nanoid } from 'nanoid';
import { Song, LibraryItem, Album, AlbumArtist, Playlist, User } from '/@/renderer/api/types';
import { Song, LibraryItem, Album, Playlist, User, AlbumArtist } from '/@/renderer/api/types';
import { ServerListItem, ServerType } from '/@/renderer/types';
import z from 'zod';
import { ndType } from './navidrome-types';
import { ssType } from '/@/renderer/api/subsonic/subsonic-types';
const getCoverArtUrl = (args: {
baseUrl: string | undefined;
@ -139,7 +140,9 @@ const normalizeAlbum = (
};
const normalizeAlbumArtist = (
item: z.infer<typeof ndType._response.albumArtist>,
item: z.infer<typeof ndType._response.albumArtist> & {
similarArtists?: z.infer<typeof ssType._response.artistInfo>['artistInfo']['similarArtist'];
},
server: ServerListItem | null,
): AlbumArtist => {
const imageUrl =
@ -159,13 +162,12 @@ const normalizeAlbumArtist = (
playCount: item.playCount,
serverId: server?.id || 'unknown',
serverType: ServerType.NAVIDROME,
similarArtists: null,
// similarArtists:
// item.similarArtists?.map((artist) => ({
// id: artist.id,
// imageUrl: artist?.artistImageUrl || null,
// name: artist.name,
// })) || null,
similarArtists:
item.similarArtists?.map((artist) => ({
id: artist.id,
imageUrl: artist?.artistImageUrl || null,
name: artist.name,
})) || null,
songCount: item.songCount,
userFavorite: item.starred,
userRating: item.rating,

View file

@ -135,7 +135,7 @@ const artistInfoParameters = z.object({
});
const artistInfo = z.object({
artistInfo2: z.object({
artistInfo: z.object({
biography: z.string().optional(),
largeImageUrl: z.string().optional(),
lastFmUrl: z.string().optional(),