|
@ -11,6 +11,7 @@ import { |
|
|
getArtistInfo, |
|
|
getArtistInfo, |
|
|
getArtists, |
|
|
getArtists, |
|
|
getArtistSongs, |
|
|
getArtistSongs, |
|
|
|
|
|
getDownloadUrl, |
|
|
getGenres, |
|
|
getGenres, |
|
|
getIndexes, |
|
|
getIndexes, |
|
|
getMusicDirectory, |
|
|
getMusicDirectory, |
|
@ -23,6 +24,8 @@ import { |
|
|
getSearch, |
|
|
getSearch, |
|
|
getSimilarSongs, |
|
|
getSimilarSongs, |
|
|
getStarred, |
|
|
getStarred, |
|
|
|
|
|
scrobble, |
|
|
|
|
|
setRating, |
|
|
star, |
|
|
star, |
|
|
startScan, |
|
|
startScan, |
|
|
unstar, |
|
|
unstar, |
|
@ -31,7 +34,7 @@ import { |
|
|
updatePlaylistSongsLg, |
|
|
updatePlaylistSongsLg, |
|
|
} from './api'; |
|
|
} from './api'; |
|
|
import { getPlaylist as jfGetPlaylist, getPlaylists as jfGetPlaylists } from './jellyfinApi'; |
|
|
import { getPlaylist as jfGetPlaylist, getPlaylists as jfGetPlaylists } from './jellyfinApi'; |
|
|
import { APIEndpoints, ServerType } from './types'; |
|
|
import { APIEndpoints, ServerType } from '../types'; |
|
|
|
|
|
|
|
|
// prettier-ignore
|
|
|
// prettier-ignore
|
|
|
const endpoints = [ |
|
|
const endpoints = [ |
|
@ -51,6 +54,7 @@ const endpoints = [ |
|
|
{ id: 'unstar', endpoint: { subsonic: unstar, jellyfin: undefined } }, |
|
|
{ id: 'unstar', endpoint: { subsonic: unstar, jellyfin: undefined } }, |
|
|
{ id: 'batchStar', endpoint: { subsonic: batchStar, jellyfin: undefined } }, |
|
|
{ id: 'batchStar', endpoint: { subsonic: batchStar, jellyfin: undefined } }, |
|
|
{ id: 'batchUnstar', endpoint: { subsonic: batchUnstar, jellyfin: undefined } }, |
|
|
{ id: 'batchUnstar', endpoint: { subsonic: batchUnstar, jellyfin: undefined } }, |
|
|
|
|
|
{ id: 'setRating', endpoint: { subsonic: setRating, jellyfin: undefined } }, |
|
|
{ id: 'getSimilarSongs', endpoint: { subsonic: getSimilarSongs, jellyfin: undefined } }, |
|
|
{ id: 'getSimilarSongs', endpoint: { subsonic: getSimilarSongs, jellyfin: undefined } }, |
|
|
{ id: 'updatePlaylistSongs', endpoint: { subsonic: updatePlaylistSongs, jellyfin: undefined } }, |
|
|
{ id: 'updatePlaylistSongs', endpoint: { subsonic: updatePlaylistSongs, jellyfin: undefined } }, |
|
|
{ id: 'updatePlaylistSongsLg', endpoint: { subsonic: updatePlaylistSongsLg, jellyfin: undefined } }, |
|
|
{ id: 'updatePlaylistSongsLg', endpoint: { subsonic: updatePlaylistSongsLg, jellyfin: undefined } }, |
|
@ -60,10 +64,12 @@ const endpoints = [ |
|
|
{ id: 'clearPlaylist', endpoint: { subsonic: clearPlaylist, jellyfin: undefined } }, |
|
|
{ id: 'clearPlaylist', endpoint: { subsonic: clearPlaylist, jellyfin: undefined } }, |
|
|
{ id: 'getGenres', endpoint: { subsonic: getGenres, jellyfin: undefined } }, |
|
|
{ id: 'getGenres', endpoint: { subsonic: getGenres, jellyfin: undefined } }, |
|
|
{ id: 'getSearch', endpoint: { subsonic: getSearch, jellyfin: undefined } }, |
|
|
{ id: 'getSearch', endpoint: { subsonic: getSearch, jellyfin: undefined } }, |
|
|
|
|
|
{ id: 'scrobble', endpoint: { subsonic: scrobble, jellyfin: undefined } }, |
|
|
{ id: 'getIndexes', endpoint: { subsonic: getIndexes, jellyfin: undefined } }, |
|
|
{ id: 'getIndexes', endpoint: { subsonic: getIndexes, jellyfin: undefined } }, |
|
|
{ id: 'getMusicFolders', endpoint: { subsonic: getMusicFolders, jellyfin: undefined } }, |
|
|
{ id: 'getMusicFolders', endpoint: { subsonic: getMusicFolders, jellyfin: undefined } }, |
|
|
{ id: 'getMusicDirectory', endpoint: { subsonic: getMusicDirectory, jellyfin: undefined } }, |
|
|
{ id: 'getMusicDirectory', endpoint: { subsonic: getMusicDirectory, jellyfin: undefined } }, |
|
|
{ id: 'getMusicDirectorySongs', endpoint: { subsonic: getMusicDirectorySongs, jellyfin: undefined } }, |
|
|
{ id: 'getMusicDirectorySongs', endpoint: { subsonic: getMusicDirectorySongs, jellyfin: undefined } }, |
|
|
|
|
|
{ id: 'getDownloadUrl', endpoint: { subsonic: getDownloadUrl, jellyfin: undefined } }, |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
export const apiController = async (options: { |
|
|
export const apiController = async (options: { |
|
@ -71,14 +77,13 @@ export const apiController = async (options: { |
|
|
endpoint: APIEndpoints; |
|
|
endpoint: APIEndpoints; |
|
|
args?: any; |
|
|
args?: any; |
|
|
}) => { |
|
|
}) => { |
|
|
const selectedEndpoint = endpoints.find((e) => e.id === options.endpoint)?.endpoint[ |
|
|
const selectedEndpoint = endpoints.find((e) => e.id === options.endpoint); |
|
|
options.serverType |
|
|
const selectedEndpointFn = selectedEndpoint!.endpoint[options.serverType]; |
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
if (!selectedEndpoint) { |
|
|
if (!selectedEndpointFn || !selectedEndpoint) { |
|
|
return notifyToast('warning', `[${options.endpoint}] not available`); |
|
|
return notifyToast('warning', `[${options.endpoint}] not available`); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const res = await selectedEndpoint(options.args); |
|
|
const res = await selectedEndpointFn(options.args); |
|
|
return res; |
|
|
return res; |
|
|
}; |
|
|
}; |
|
|