export type GetApiSongsIdPlayM3u8Args = {id: number, format?: string | undefined, quality?: string | undefined, track?: number | undefined, prefetch?: string | undefined, media?: string | undefined, hls?: string | undefined, normalize?: string | undefined, radio_transcode?: string | undefined, seek?: number | undefined, speed?: number | undefined}; export type GetApiSongsIdPlayM3u8Options = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * 流式播放歌曲 * * GET /songs/{id}/play.m3u8 */ export const getApiSongsIdPlayM3u8 = async (args: GetApiSongsIdPlayM3u8Args, options: GetApiSongsIdPlayM3u8Options) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.format != null) query.append("format", String(args.format)) if (args.quality != null) query.append("quality", String(args.quality)) if (args.track != null) query.append("track", String(args.track)) if (args.prefetch != null) query.append("prefetch", String(args.prefetch)) if (args.media != null) query.append("media", String(args.media)) if (args.hls != null) query.append("hls", String(args.hls)) if (args.normalize != null) query.append("normalize", String(args.normalize)) if (args.radio_transcode != null) query.append("radio_transcode", String(args.radio_transcode)) if (args.seek != null) query.append("seek", String(args.seek)) if (args.speed != null) query.append("speed", String(args.speed)) if (BearerAuth !== undefined) headers.set("Authorization", BearerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/songs/${encodeURIComponent(String(args.id))}/play.m3u8${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() };