export type GetApiSongsIdHlsPlaylistArgs = {id: number, u: string}; export type GetApiSongsIdHlsPlaylistOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * 反代 HLS 子层 m3u8 * * GET /songs/{id}/hls/playlist */ export const getApiSongsIdHlsPlaylist = async (args: GetApiSongsIdHlsPlaylistArgs, options: GetApiSongsIdHlsPlaylistOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/vnd.apple.mpegurl") if (args.u != null) query.append("u", String(args.u)) if (BearerAuth !== undefined) headers.set("Authorization", BearerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/songs/${encodeURIComponent(String(args.id))}/hls/playlist${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };