Add similarSongs endpoint for jellyfin

This commit is contained in:
jeffvli
2021-12-27 14:05:55 -08:00
committed by Jeff
parent 1b1696b96a
commit 80bbb7626e
2 changed files with 16 additions and 2 deletions

View File

@@ -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 } },

View File

@@ -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 },