mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 12:30:12 +02:00
Album radio (#1759)
* added album radio feature --------- Co-authored-by: jeffvli <jeffvictorli@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a78f5803a5
commit
4918b412b2
@@ -308,6 +308,20 @@ export const controller: GeneralController = {
|
||||
}),
|
||||
);
|
||||
},
|
||||
getAlbumRadio(args) {
|
||||
const server = getServerById(args.apiClientProps.serverId);
|
||||
|
||||
if (!server) {
|
||||
throw new Error(
|
||||
`${i18n.t('error.apiRouteError', { postProcess: 'sentenceCase' })}: getAlbumRadio`,
|
||||
);
|
||||
}
|
||||
|
||||
return apiController(
|
||||
'getAlbumRadio',
|
||||
server.type,
|
||||
)?.(addContext({ ...args, apiClientProps: { ...args.apiClientProps, server } }));
|
||||
},
|
||||
getArtistList(args) {
|
||||
const server = getServerById(args.apiClientProps.serverId);
|
||||
|
||||
|
||||
@@ -433,6 +433,34 @@ export const JellyfinController: InternalControllerEndpoint = {
|
||||
apiClientProps,
|
||||
query: { ...query, limit: 1, startIndex: 0 },
|
||||
}).then((result) => result!.totalRecordCount!),
|
||||
getAlbumRadio: async (args) => {
|
||||
const { apiClientProps, query } = args;
|
||||
|
||||
// For Jellyfin, use instant mix for album radio
|
||||
const res = await jfApiClient(apiClientProps).getInstantMix({
|
||||
params: {
|
||||
itemId: query.albumId,
|
||||
},
|
||||
query: {
|
||||
Fields: JF_FIELDS.SONG,
|
||||
Limit: query.count,
|
||||
UserId: apiClientProps.server?.userId || undefined,
|
||||
},
|
||||
});
|
||||
|
||||
if (res.status !== 200) {
|
||||
throw new Error('Failed to get album radio songs');
|
||||
}
|
||||
|
||||
return res.body.Items.map((song) =>
|
||||
jfNormalize.song(
|
||||
song,
|
||||
apiClientProps.server,
|
||||
args.context?.pathReplace,
|
||||
args.context?.pathReplaceWith,
|
||||
),
|
||||
);
|
||||
},
|
||||
getArtistList: async (args) => {
|
||||
const { apiClientProps, query } = args;
|
||||
|
||||
|
||||
@@ -376,6 +376,32 @@ export const NavidromeController: InternalControllerEndpoint = {
|
||||
apiClientProps,
|
||||
query: { ...query, limit: 1, startIndex: 0 },
|
||||
}).then((result) => result!.totalRecordCount!),
|
||||
getAlbumRadio: async (args) => {
|
||||
const { apiClientProps, query } = args;
|
||||
|
||||
// Use getSimilarSongs API for album radio
|
||||
const res = await ssApiClient({
|
||||
...apiClientProps,
|
||||
silent: true,
|
||||
}).getSimilarSongs({
|
||||
query: {
|
||||
count: query.count,
|
||||
id: query.albumId,
|
||||
},
|
||||
});
|
||||
|
||||
if (res.status !== 200) {
|
||||
throw new Error('Failed to get album radio songs');
|
||||
}
|
||||
|
||||
if (!res.body.similarSongs?.song) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return res.body.similarSongs.song.map((song) =>
|
||||
ssNormalize.song(song, apiClientProps.server),
|
||||
);
|
||||
},
|
||||
getArtistList: async (args) => {
|
||||
const { apiClientProps, query } = args;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
AlbumArtistListQuery,
|
||||
AlbumDetailQuery,
|
||||
AlbumListQuery,
|
||||
AlbumRadioQuery,
|
||||
ArtistListQuery,
|
||||
ArtistRadioQuery,
|
||||
FolderQuery,
|
||||
@@ -348,6 +349,10 @@ export const queryKeys: Record<
|
||||
root: (serverId: string) => [serverId] as const,
|
||||
},
|
||||
songs: {
|
||||
albumRadio: (serverId: string, query?: AlbumRadioQuery) => {
|
||||
if (query) return [serverId, 'songs', 'albumRadio', query] as const;
|
||||
return [serverId, 'songs', 'albumRadio'] as const;
|
||||
},
|
||||
artistRadio: (serverId: string, query?: ArtistRadioQuery) => {
|
||||
if (query) return [serverId, 'songs', 'artistRadio', query] as const;
|
||||
return [serverId, 'songs', 'artistRadio'] as const;
|
||||
|
||||
@@ -676,6 +676,33 @@ export const SubsonicController: InternalControllerEndpoint = {
|
||||
|
||||
return totalRecordCount;
|
||||
},
|
||||
getAlbumRadio: async (args) => {
|
||||
const { apiClientProps, context, query } = args;
|
||||
|
||||
const res = await ssApiClient(apiClientProps).getSimilarSongs({
|
||||
query: {
|
||||
count: query.count,
|
||||
id: query.albumId,
|
||||
},
|
||||
});
|
||||
|
||||
if (res.status !== 200) {
|
||||
throw new Error('Failed to get album radio songs');
|
||||
}
|
||||
|
||||
if (!res.body.similarSongs?.song) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return res.body.similarSongs.song.map((song) =>
|
||||
ssNormalize.song(
|
||||
song,
|
||||
apiClientProps.server,
|
||||
context?.pathReplace,
|
||||
context?.pathReplaceWith,
|
||||
),
|
||||
);
|
||||
},
|
||||
getArtistList: async (args) => {
|
||||
const { apiClientProps, query } = args;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user