mirror of
https://github.com/jeffvli/sonixd.git
synced 2026-04-29 02:32:37 -04:00
Add similarSongs endpoint for jellyfin
This commit is contained in:
@@ -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 } },
|
||||
|
||||
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user