mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 15:02:42 +01:00
redid cover art (again...) and impl a ListItem
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user