added top songs to artist view

This commit is contained in:
austinried
2021-07-17 10:39:18 +09:00
parent 62a721ba4d
commit de342c0830
10 changed files with 168 additions and 119 deletions

View File

@@ -10,6 +10,7 @@ import {
GetCoverArtParams,
GetIndexesParams,
GetMusicDirectoryParams,
GetTopSongsParams,
StreamParams,
} from '@app/subsonic/params'
import {
@@ -22,6 +23,7 @@ import {
GetArtistsResponse,
GetIndexesResponse,
GetMusicDirectoryResponse,
GetTopSongsResponse,
SubsonicResponse,
} from '@app/subsonic/responses'
import { Server } from '@app/models/settings'
@@ -165,6 +167,11 @@ export class SubsonicApiClient {
return new SubsonicResponse<GetArtistResponse>(xml, new GetArtistResponse(xml))
}
async getTopSongs(params: GetTopSongsParams): Promise<SubsonicResponse<GetTopSongsResponse>> {
const xml = await this.apiGetXml('getTopSongs', params)
return new SubsonicResponse<GetTopSongsResponse>(xml, new GetTopSongsResponse(xml))
}
//
// Album/song lists
//

View File

@@ -27,6 +27,11 @@ export type GetArtistParams = {
id: string
}
export type GetTopSongsParams = {
artist: string
count?: number
}
//
// Album/song lists
//

View File

@@ -116,6 +116,17 @@ export class GetAlbumResponse {
}
}
export class GetTopSongsResponse {
songs: ChildElement[] = []
constructor(xml: Document) {
const childElements = xml.getElementsByTagName('song')
for (let i = 0; i < childElements.length; i++) {
this.songs.push(new ChildElement(childElements[i]))
}
}
}
//
// Album/song lists
//