redid cover art (again...) and impl a ListItem

This commit is contained in:
austinried
2021-07-24 17:17:55 +09:00
parent 6dd17f2797
commit fbf6060db4
24 changed files with 602 additions and 597 deletions

View File

@@ -13,6 +13,7 @@ import {
GetPlaylistParams,
GetPlaylistsParams,
GetTopSongsParams,
Search3Params,
StreamParams,
} from '@app/subsonic/params'
import {
@@ -28,6 +29,7 @@ import {
GetPlaylistResponse,
GetPlaylistsResponse,
GetTopSongsResponse,
Search3Response,
SubsonicResponse,
} from '@app/subsonic/responses'
import { Server } from '@app/models/settings'
@@ -220,4 +222,13 @@ export class SubsonicApiClient {
streamUri(params: StreamParams): string {
return this.buildUrl('stream', params)
}
//
// Searching
//
async search3(params: Search3Params): Promise<SubsonicResponse<Search3Response>> {
const xml = await this.apiGetXml('search3', params)
return new SubsonicResponse<Search3Response>(xml, new Search3Response(xml))
}
}

View File

@@ -99,3 +99,18 @@ export type StreamParams = {
format?: string
estimateContentLength?: boolean
}
//
// Searching
//
export type Search3Params = {
query: string
artistCount?: number
artistOffset?: number
albumCount?: number
albumOffset?: number
songCount?: number
songOffset?: number
musicFolderId?: string
}

View File

@@ -178,3 +178,30 @@ export class GetPlaylistResponse {
this.playlist = new PlaylistWithSongsElement(xml.getElementsByTagName('playlist')[0])
}
}
//
// Searching
//
export class Search3Response {
artists: ArtistID3Element[] = []
albums: AlbumID3Element[] = []
songs: ChildElement[] = []
constructor(xml: Document) {
const artistElements = xml.getElementsByTagName('artist')
for (let i = 0; i < artistElements.length; i++) {
this.artists.push(new ArtistID3Element(artistElements[i]))
}
const albumElements = xml.getElementsByTagName('album')
for (let i = 0; i < albumElements.length; i++) {
this.albums.push(new AlbumID3Element(albumElements[i]))
}
const songElements = xml.getElementsByTagName('song')
for (let i = 0; i < songElements.length; i++) {
this.songs.push(new ChildElement(songElements[i]))
}
}
}