refactor star

This commit is contained in:
austinried
2022-03-20 09:33:15 +09:00
parent 1803e9dc7c
commit a15159014c
10 changed files with 122 additions and 146 deletions

View File

@@ -11,6 +11,7 @@ import {
GetMusicDirectoryParams,
GetPlaylistParams,
GetPlaylistsParams,
GetSongParams,
GetTopSongsParams,
ScrobbleParams,
Search3Params,
@@ -29,6 +30,7 @@ import {
GetMusicDirectoryResponse,
GetPlaylistResponse,
GetPlaylistsResponse,
GetSongResponse,
GetTopSongsResponse,
Search3Response,
SubsonicResponse,
@@ -180,6 +182,11 @@ export class SubsonicApiClient {
return new SubsonicResponse<GetTopSongsResponse>(xml, new GetTopSongsResponse(xml))
}
async getSong(params: GetSongParams): Promise<SubsonicResponse<GetSongResponse>> {
const xml = await this.apiGetXml('getSong', params)
return new SubsonicResponse<GetSongResponse>(xml, new GetSongResponse(xml))
}
//
// Album/song lists
//

View File

@@ -27,6 +27,10 @@ export type GetArtistParams = {
id: string
}
export type GetSongParams = {
id: string
}
export type GetTopSongsParams = {
artist: string
count?: number

View File

@@ -129,6 +129,14 @@ export class GetTopSongsResponse {
}
}
export class GetSongResponse {
song: ChildElement
constructor(xml: Document) {
this.song = new ChildElement(xml.getElementsByTagName('song')[0])
}
}
//
// Album/song lists
//