2023-04-23 19:57:10 -07:00
|
|
|
import {
|
2023-07-01 19:10:05 -07:00
|
|
|
AlbumArtistDetailArgs,
|
|
|
|
|
AlbumArtistDetailResponse,
|
|
|
|
|
AddToPlaylistArgs,
|
|
|
|
|
AddToPlaylistResponse,
|
|
|
|
|
CreatePlaylistResponse,
|
|
|
|
|
CreatePlaylistArgs,
|
|
|
|
|
DeletePlaylistArgs,
|
|
|
|
|
DeletePlaylistResponse,
|
|
|
|
|
AlbumArtistListResponse,
|
|
|
|
|
AlbumArtistListArgs,
|
|
|
|
|
albumArtistListSortMap,
|
|
|
|
|
sortOrderMap,
|
|
|
|
|
AuthenticationResponse,
|
|
|
|
|
UserListResponse,
|
|
|
|
|
UserListArgs,
|
|
|
|
|
userListSortMap,
|
|
|
|
|
GenreListArgs,
|
|
|
|
|
GenreListResponse,
|
|
|
|
|
AlbumDetailResponse,
|
|
|
|
|
AlbumDetailArgs,
|
|
|
|
|
AlbumListArgs,
|
|
|
|
|
albumListSortMap,
|
|
|
|
|
AlbumListResponse,
|
|
|
|
|
SongListResponse,
|
|
|
|
|
SongListArgs,
|
|
|
|
|
songListSortMap,
|
|
|
|
|
SongDetailResponse,
|
|
|
|
|
SongDetailArgs,
|
|
|
|
|
UpdatePlaylistArgs,
|
|
|
|
|
UpdatePlaylistResponse,
|
|
|
|
|
PlaylistListResponse,
|
|
|
|
|
PlaylistDetailArgs,
|
|
|
|
|
PlaylistListArgs,
|
|
|
|
|
playlistListSortMap,
|
|
|
|
|
PlaylistDetailResponse,
|
|
|
|
|
PlaylistSongListArgs,
|
|
|
|
|
PlaylistSongListResponse,
|
|
|
|
|
RemoveFromPlaylistResponse,
|
|
|
|
|
RemoveFromPlaylistArgs,
|
2023-04-23 19:57:10 -07:00
|
|
|
} from '../types';
|
|
|
|
|
import { ndApiClient } from '/@/renderer/api/navidrome/navidrome-api';
|
|
|
|
|
import { ndNormalize } from '/@/renderer/api/navidrome/navidrome-normalize';
|
|
|
|
|
import { ndType } from '/@/renderer/api/navidrome/navidrome-types';
|
2023-05-20 02:24:40 -07:00
|
|
|
import { ssApiClient } from '/@/renderer/api/subsonic/subsonic-api';
|
2023-04-23 19:57:10 -07:00
|
|
|
|
|
|
|
|
const authenticate = async (
|
2023-07-01 19:10:05 -07:00
|
|
|
url: string,
|
|
|
|
|
body: { password: string; username: string },
|
2023-04-23 19:57:10 -07:00
|
|
|
): Promise<AuthenticationResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const cleanServerUrl = url.replace(/\/$/, '');
|
|
|
|
|
|
|
|
|
|
const res = await ndApiClient({ server: null, url: cleanServerUrl }).authenticate({
|
|
|
|
|
body: {
|
|
|
|
|
password: body.password,
|
|
|
|
|
username: body.username,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to authenticate');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
credential: `u=${body.username}&s=${res.body.data.subsonicSalt}&t=${res.body.data.subsonicToken}`,
|
|
|
|
|
ndCredential: res.body.data.token,
|
|
|
|
|
userId: res.body.data.id,
|
|
|
|
|
username: res.body.data.username,
|
|
|
|
|
};
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getUserList = async (args: UserListArgs): Promise<UserListResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, apiClientProps } = args;
|
|
|
|
|
|
|
|
|
|
const res = await ndApiClient(apiClientProps).getUserList({
|
|
|
|
|
query: {
|
|
|
|
|
_end: query.startIndex + (query.limit || 0),
|
|
|
|
|
_order: sortOrderMap.navidrome[query.sortOrder],
|
|
|
|
|
_sort: userListSortMap.navidrome[query.sortBy],
|
|
|
|
|
_start: query.startIndex,
|
|
|
|
|
...query._custom?.navidrome,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to get user list');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
items: res.body.data.map((user) => ndNormalize.user(user)),
|
|
|
|
|
startIndex: query?.startIndex || 0,
|
|
|
|
|
totalRecordCount: Number(res.body.headers.get('x-total-count') || 0),
|
|
|
|
|
};
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getGenreList = async (args: GenreListArgs): Promise<GenreListResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { apiClientProps } = args;
|
2023-04-23 19:57:10 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const res = await ndApiClient(apiClientProps).getGenreList({});
|
2023-04-23 19:57:10 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to get genre list');
|
|
|
|
|
}
|
2023-04-23 19:57:10 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return {
|
|
|
|
|
items: res.body.data,
|
|
|
|
|
startIndex: 0,
|
|
|
|
|
totalRecordCount: Number(res.body.headers.get('x-total-count') || 0),
|
|
|
|
|
};
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getAlbumArtistDetail = async (
|
2023-07-01 19:10:05 -07:00
|
|
|
args: AlbumArtistDetailArgs,
|
2023-04-23 19:57:10 -07:00
|
|
|
): Promise<AlbumArtistDetailResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, apiClientProps } = args;
|
|
|
|
|
|
|
|
|
|
const res = await ndApiClient(apiClientProps).getAlbumArtistDetail({
|
|
|
|
|
params: {
|
|
|
|
|
id: query.id,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const artistInfoRes = await ssApiClient(apiClientProps).getArtistInfo({
|
|
|
|
|
query: {
|
|
|
|
|
count: 10,
|
|
|
|
|
id: query.id,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to get album artist detail');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!apiClientProps.server) {
|
|
|
|
|
throw new Error('Server is required');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ndNormalize.albumArtist(
|
|
|
|
|
{
|
|
|
|
|
...res.body.data,
|
|
|
|
|
...(artistInfoRes.status === 200 && {
|
|
|
|
|
similarArtists: artistInfoRes.body.artistInfo.similarArtist,
|
|
|
|
|
...(!res.body.data.largeImageUrl && {
|
|
|
|
|
largeImageUrl: artistInfoRes.body.artistInfo.largeImageUrl,
|
|
|
|
|
}),
|
|
|
|
|
...(!res.body.data.mediumImageUrl && {
|
|
|
|
|
largeImageUrl: artistInfoRes.body.artistInfo.mediumImageUrl,
|
|
|
|
|
}),
|
|
|
|
|
...(!res.body.data.smallImageUrl && {
|
|
|
|
|
largeImageUrl: artistInfoRes.body.artistInfo.smallImageUrl,
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
apiClientProps.server,
|
|
|
|
|
);
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getAlbumArtistList = async (args: AlbumArtistListArgs): Promise<AlbumArtistListResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, apiClientProps } = args;
|
|
|
|
|
|
|
|
|
|
const res = await ndApiClient(apiClientProps).getAlbumArtistList({
|
|
|
|
|
query: {
|
|
|
|
|
_end: query.startIndex + (query.limit || 0),
|
|
|
|
|
_order: sortOrderMap.navidrome[query.sortOrder],
|
|
|
|
|
_sort: albumArtistListSortMap.navidrome[query.sortBy],
|
|
|
|
|
_start: query.startIndex,
|
|
|
|
|
name: query.searchTerm,
|
|
|
|
|
...query._custom?.navidrome,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to get album artist list');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
items: res.body.data.map((albumArtist) =>
|
|
|
|
|
ndNormalize.albumArtist(albumArtist, apiClientProps.server),
|
|
|
|
|
),
|
|
|
|
|
startIndex: query.startIndex,
|
|
|
|
|
totalRecordCount: Number(res.body.headers.get('x-total-count') || 0),
|
|
|
|
|
};
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getAlbumDetail = async (args: AlbumDetailArgs): Promise<AlbumDetailResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, apiClientProps } = args;
|
|
|
|
|
|
|
|
|
|
const albumRes = await ndApiClient(apiClientProps).getAlbumDetail({
|
|
|
|
|
params: {
|
|
|
|
|
id: query.id,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const songsData = await ndApiClient(apiClientProps).getSongList({
|
|
|
|
|
query: {
|
|
|
|
|
_end: 0,
|
|
|
|
|
_order: 'ASC',
|
|
|
|
|
_sort: 'album',
|
|
|
|
|
_start: 0,
|
|
|
|
|
album_id: [query.id],
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (albumRes.status !== 200 || songsData.status !== 200) {
|
|
|
|
|
throw new Error('Failed to get album detail');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ndNormalize.album(
|
|
|
|
|
{ ...albumRes.body.data, songs: songsData.body.data },
|
|
|
|
|
apiClientProps.server,
|
|
|
|
|
);
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getAlbumList = async (args: AlbumListArgs): Promise<AlbumListResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, apiClientProps } = args;
|
|
|
|
|
|
|
|
|
|
const res = await ndApiClient(apiClientProps).getAlbumList({
|
|
|
|
|
query: {
|
|
|
|
|
_end: query.startIndex + (query.limit || 0),
|
|
|
|
|
_order: sortOrderMap.navidrome[query.sortOrder],
|
|
|
|
|
_sort: albumListSortMap.navidrome[query.sortBy],
|
|
|
|
|
_start: query.startIndex,
|
|
|
|
|
artist_id: query.artistIds?.[0],
|
|
|
|
|
name: query.searchTerm,
|
|
|
|
|
...query._custom?.navidrome,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to get album list');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
items: res.body.data.map((album) => ndNormalize.album(album, apiClientProps.server)),
|
|
|
|
|
startIndex: query?.startIndex || 0,
|
|
|
|
|
totalRecordCount: Number(res.body.headers.get('x-total-count') || 0),
|
|
|
|
|
};
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getSongList = async (args: SongListArgs): Promise<SongListResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, apiClientProps } = args;
|
|
|
|
|
|
|
|
|
|
const res = await ndApiClient(apiClientProps).getSongList({
|
|
|
|
|
query: {
|
|
|
|
|
_end: query.startIndex + (query.limit || -1),
|
|
|
|
|
_order: sortOrderMap.navidrome[query.sortOrder],
|
|
|
|
|
_sort: songListSortMap.navidrome[query.sortBy],
|
|
|
|
|
_start: query.startIndex,
|
|
|
|
|
album_artist_id: query.artistIds,
|
|
|
|
|
album_id: query.albumIds,
|
|
|
|
|
title: query.searchTerm,
|
|
|
|
|
...query._custom?.navidrome,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to get song list');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
items: res.body.data.map((song) => ndNormalize.song(song, apiClientProps.server, '')),
|
|
|
|
|
startIndex: query?.startIndex || 0,
|
|
|
|
|
totalRecordCount: Number(res.body.headers.get('x-total-count') || 0),
|
|
|
|
|
};
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getSongDetail = async (args: SongDetailArgs): Promise<SongDetailResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, apiClientProps } = args;
|
2023-04-23 19:57:10 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const res = await ndApiClient(apiClientProps).getSongDetail({
|
|
|
|
|
params: {
|
|
|
|
|
id: query.id,
|
|
|
|
|
},
|
|
|
|
|
});
|
2023-04-23 19:57:10 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to get song detail');
|
|
|
|
|
}
|
2023-04-23 19:57:10 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return ndNormalize.song(res.body.data, apiClientProps.server, '');
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const createPlaylist = async (args: CreatePlaylistArgs): Promise<CreatePlaylistResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { body, apiClientProps } = args;
|
|
|
|
|
|
|
|
|
|
const res = await ndApiClient(apiClientProps).createPlaylist({
|
|
|
|
|
body: {
|
|
|
|
|
comment: body.comment,
|
|
|
|
|
name: body.name,
|
|
|
|
|
public: body._custom?.navidrome?.public,
|
|
|
|
|
rules: body._custom?.navidrome?.rules,
|
|
|
|
|
sync: body._custom?.navidrome?.sync,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to create playlist');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
id: res.body.data.id,
|
|
|
|
|
};
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const updatePlaylist = async (args: UpdatePlaylistArgs): Promise<UpdatePlaylistResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, body, apiClientProps } = args;
|
|
|
|
|
|
|
|
|
|
const res = await ndApiClient(apiClientProps).updatePlaylist({
|
|
|
|
|
body: {
|
|
|
|
|
comment: body.comment || '',
|
|
|
|
|
name: body.name,
|
|
|
|
|
public: body._custom?.navidrome?.public || false,
|
|
|
|
|
rules: body._custom?.navidrome?.rules ? body._custom.navidrome.rules : undefined,
|
|
|
|
|
sync: body._custom?.navidrome?.sync || undefined,
|
|
|
|
|
},
|
|
|
|
|
params: {
|
|
|
|
|
id: query.id,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to update playlist');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const deletePlaylist = async (args: DeletePlaylistArgs): Promise<DeletePlaylistResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, apiClientProps } = args;
|
2023-04-23 19:57:10 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const res = await ndApiClient(apiClientProps).deletePlaylist({
|
|
|
|
|
body: null,
|
|
|
|
|
params: {
|
|
|
|
|
id: query.id,
|
|
|
|
|
},
|
|
|
|
|
});
|
2023-04-23 19:57:10 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to delete playlist');
|
|
|
|
|
}
|
2023-04-23 19:57:10 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return null;
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getPlaylistList = async (args: PlaylistListArgs): Promise<PlaylistListResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, apiClientProps } = args;
|
|
|
|
|
|
|
|
|
|
const res = await ndApiClient(apiClientProps).getPlaylistList({
|
|
|
|
|
query: {
|
|
|
|
|
_end: query.startIndex + (query.limit || 0),
|
|
|
|
|
_order: sortOrderMap.navidrome[query.sortOrder],
|
|
|
|
|
_sort: query.sortBy ? playlistListSortMap.navidrome[query.sortBy] : undefined,
|
|
|
|
|
_start: query.startIndex,
|
|
|
|
|
...query._custom?.navidrome,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to get playlist list');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
items: res.body.data.map((item) => ndNormalize.playlist(item, apiClientProps.server)),
|
|
|
|
|
startIndex: query?.startIndex || 0,
|
|
|
|
|
totalRecordCount: Number(res.body.headers.get('x-total-count') || 0),
|
|
|
|
|
};
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getPlaylistDetail = async (args: PlaylistDetailArgs): Promise<PlaylistDetailResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, apiClientProps } = args;
|
2023-04-23 19:57:10 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const res = await ndApiClient(apiClientProps).getPlaylistDetail({
|
|
|
|
|
params: {
|
|
|
|
|
id: query.id,
|
|
|
|
|
},
|
|
|
|
|
});
|
2023-04-23 19:57:10 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to get playlist detail');
|
|
|
|
|
}
|
2023-04-23 19:57:10 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return ndNormalize.playlist(res.body.data, apiClientProps.server);
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getPlaylistSongList = async (
|
2023-07-01 19:10:05 -07:00
|
|
|
args: PlaylistSongListArgs,
|
2023-04-23 19:57:10 -07:00
|
|
|
): Promise<PlaylistSongListResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, apiClientProps } = args;
|
|
|
|
|
|
|
|
|
|
const res = await ndApiClient(apiClientProps).getPlaylistSongList({
|
|
|
|
|
params: {
|
|
|
|
|
id: query.id,
|
|
|
|
|
},
|
|
|
|
|
query: {
|
|
|
|
|
_end: query.startIndex + (query.limit || 0),
|
|
|
|
|
_order: query.sortOrder ? sortOrderMap.navidrome[query.sortOrder] : 'ASC',
|
|
|
|
|
_sort: query.sortBy
|
|
|
|
|
? songListSortMap.navidrome[query.sortBy]
|
|
|
|
|
: ndType._enum.songList.ID,
|
|
|
|
|
_start: query.startIndex,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to get playlist song list');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
items: res.body.data.map((item) => ndNormalize.song(item, apiClientProps.server, '')),
|
|
|
|
|
startIndex: query?.startIndex || 0,
|
|
|
|
|
totalRecordCount: Number(res.body.headers.get('x-total-count') || 0),
|
|
|
|
|
};
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const addToPlaylist = async (args: AddToPlaylistArgs): Promise<AddToPlaylistResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { body, query, apiClientProps } = args;
|
|
|
|
|
|
|
|
|
|
const res = await ndApiClient(apiClientProps).addToPlaylist({
|
|
|
|
|
body: {
|
|
|
|
|
ids: body.songId,
|
|
|
|
|
},
|
|
|
|
|
params: {
|
|
|
|
|
id: query.id,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to add to playlist');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const removeFromPlaylist = async (
|
2023-07-01 19:10:05 -07:00
|
|
|
args: RemoveFromPlaylistArgs,
|
2023-04-23 19:57:10 -07:00
|
|
|
): Promise<RemoveFromPlaylistResponse> => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { query, apiClientProps } = args;
|
|
|
|
|
|
|
|
|
|
const res = await ndApiClient(apiClientProps).removeFromPlaylist({
|
|
|
|
|
body: null,
|
|
|
|
|
params: {
|
|
|
|
|
id: query.id,
|
|
|
|
|
},
|
|
|
|
|
query: {
|
|
|
|
|
id: query.songId,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status !== 200) {
|
|
|
|
|
throw new Error('Failed to remove from playlist');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const ndController = {
|
2023-07-01 19:10:05 -07:00
|
|
|
addToPlaylist,
|
|
|
|
|
authenticate,
|
|
|
|
|
createPlaylist,
|
|
|
|
|
deletePlaylist,
|
|
|
|
|
getAlbumArtistDetail,
|
|
|
|
|
getAlbumArtistList,
|
|
|
|
|
getAlbumDetail,
|
|
|
|
|
getAlbumList,
|
|
|
|
|
getGenreList,
|
|
|
|
|
getPlaylistDetail,
|
|
|
|
|
getPlaylistList,
|
|
|
|
|
getPlaylistSongList,
|
|
|
|
|
getSongDetail,
|
|
|
|
|
getSongList,
|
|
|
|
|
getUserList,
|
|
|
|
|
removeFromPlaylist,
|
|
|
|
|
updatePlaylist,
|
2023-04-23 19:57:10 -07:00
|
|
|
};
|