Re-add artistInfo api call for navidrome
This commit is contained in:
parent
645b4fe332
commit
c854fd0a5b
3 changed files with 29 additions and 11 deletions
|
@ -42,6 +42,7 @@ import {
|
||||||
import { ndApiClient } from '/@/renderer/api/navidrome/navidrome-api';
|
import { ndApiClient } from '/@/renderer/api/navidrome/navidrome-api';
|
||||||
import { ndNormalize } from '/@/renderer/api/navidrome/navidrome-normalize';
|
import { ndNormalize } from '/@/renderer/api/navidrome/navidrome-normalize';
|
||||||
import { ndType } from '/@/renderer/api/navidrome/navidrome-types';
|
import { ndType } from '/@/renderer/api/navidrome/navidrome-types';
|
||||||
|
import { ssApiClient } from '/@/renderer/api/subsonic/subsonic-api';
|
||||||
|
|
||||||
const authenticate = async (
|
const authenticate = async (
|
||||||
url: string,
|
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) {
|
if (res.status !== 200) {
|
||||||
throw new Error('Failed to get album artist detail');
|
throw new Error('Failed to get album artist detail');
|
||||||
}
|
}
|
||||||
|
@ -127,7 +135,15 @@ const getAlbumArtistDetail = async (
|
||||||
throw new Error('Server is required');
|
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> => {
|
const getAlbumArtistList = async (args: AlbumArtistListArgs): Promise<AlbumArtistListResponse> => {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import { nanoid } from 'nanoid';
|
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 { ServerListItem, ServerType } from '/@/renderer/types';
|
||||||
import z from 'zod';
|
import z from 'zod';
|
||||||
import { ndType } from './navidrome-types';
|
import { ndType } from './navidrome-types';
|
||||||
|
import { ssType } from '/@/renderer/api/subsonic/subsonic-types';
|
||||||
|
|
||||||
const getCoverArtUrl = (args: {
|
const getCoverArtUrl = (args: {
|
||||||
baseUrl: string | undefined;
|
baseUrl: string | undefined;
|
||||||
|
@ -139,7 +140,9 @@ const normalizeAlbum = (
|
||||||
};
|
};
|
||||||
|
|
||||||
const normalizeAlbumArtist = (
|
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,
|
server: ServerListItem | null,
|
||||||
): AlbumArtist => {
|
): AlbumArtist => {
|
||||||
const imageUrl =
|
const imageUrl =
|
||||||
|
@ -159,13 +162,12 @@ const normalizeAlbumArtist = (
|
||||||
playCount: item.playCount,
|
playCount: item.playCount,
|
||||||
serverId: server?.id || 'unknown',
|
serverId: server?.id || 'unknown',
|
||||||
serverType: ServerType.NAVIDROME,
|
serverType: ServerType.NAVIDROME,
|
||||||
similarArtists: null,
|
similarArtists:
|
||||||
// similarArtists:
|
item.similarArtists?.map((artist) => ({
|
||||||
// item.similarArtists?.map((artist) => ({
|
id: artist.id,
|
||||||
// id: artist.id,
|
imageUrl: artist?.artistImageUrl || null,
|
||||||
// imageUrl: artist?.artistImageUrl || null,
|
name: artist.name,
|
||||||
// name: artist.name,
|
})) || null,
|
||||||
// })) || null,
|
|
||||||
songCount: item.songCount,
|
songCount: item.songCount,
|
||||||
userFavorite: item.starred,
|
userFavorite: item.starred,
|
||||||
userRating: item.rating,
|
userRating: item.rating,
|
||||||
|
|
|
@ -135,7 +135,7 @@ const artistInfoParameters = z.object({
|
||||||
});
|
});
|
||||||
|
|
||||||
const artistInfo = z.object({
|
const artistInfo = z.object({
|
||||||
artistInfo2: z.object({
|
artistInfo: z.object({
|
||||||
biography: z.string().optional(),
|
biography: z.string().optional(),
|
||||||
largeImageUrl: z.string().optional(),
|
largeImageUrl: z.string().optional(),
|
||||||
lastFmUrl: z.string().optional(),
|
lastFmUrl: z.string().optional(),
|
||||||
|
|
Reference in a new issue