diff --git a/src/api/controller.ts b/src/api/controller.ts index f6d9080..cdc1b97 100644 --- a/src/api/controller.ts +++ b/src/api/controller.ts @@ -62,6 +62,7 @@ import { updatePlaylistSongsLg as jfUpdatePlaylingSongsLg, updatePlaylist as jfUpdatePlaylist, getSongs as jfGetSongs, + getSimilarSongs as jfGetSimilarSongs, } from './jellyfinApi'; import { APIEndpoints, ServerType } from '../types'; @@ -83,7 +84,7 @@ const endpoints = [ { id: 'batchStar', endpoint: { subsonic: batchStar, jellyfin: jfBatchStar } }, { id: 'batchUnstar', endpoint: { subsonic: batchUnstar, jellyfin: jfBatchUnstar } }, { id: 'setRating', endpoint: { subsonic: setRating, jellyfin: undefined } }, - { id: 'getSimilarSongs', endpoint: { subsonic: getSimilarSongs, jellyfin: undefined } }, + { id: 'getSimilarSongs', endpoint: { subsonic: getSimilarSongs, jellyfin: jfGetSimilarSongs } }, { id: 'getGenres', endpoint: { subsonic: getGenres, jellyfin: jfGetGenres } }, { id: 'getSearch', endpoint: { subsonic: getSearch, jellyfin: jfGetSearch } }, { id: 'scrobble', endpoint: { subsonic: scrobble, jellyfin: jfScrobble } }, diff --git a/src/api/jellyfinApi.ts b/src/api/jellyfinApi.ts index 177adaf..3a3de30 100644 --- a/src/api/jellyfinApi.ts +++ b/src/api/jellyfinApi.ts @@ -476,7 +476,7 @@ export const getArtist = async (options: { id: string; musicFolderId?: string }) }); const { data: similarData } = await jellyfinApi.get(`/artists/${options.id}/similar`, { - params: { limit: 15 }, + params: { limit: 15, userId: auth.username, parentId: options.musicFolderId }, }); return normalizeArtist({ @@ -616,6 +616,19 @@ export const batchUnstar = async (options: { ids: string[] }) => { return res; }; +export const getSimilarSongs = async (options: { id: string; musicFolderId?: string }) => { + const { data } = await jellyfinApi.get(`/items/${options.id}/instantmix`, { + params: { + userId: auth.username, + fields: 'Genres, DateCreated, MediaSources, UserData, ParentId', + parentId: options.musicFolderId, + limit: 100, + }, + }); + + return (data.Items || []).map((entry: any) => normalizeSong(entry)); +}; + export const getGenres = async (options: { musicFolderId?: string }) => { const { data } = await jellyfinApi.get(`/musicgenres`, { params: { parentId: options.musicFolderId },