export type GetApiApiV1MusicStreamIdArgs = {id: string, transcode?: boolean | undefined, bitrate?: number | undefined}; export type GetApiApiV1MusicStreamIdOptions = {baseUrl: string, LocalUserJWTQueryParameter?: string | undefined, fetch?: typeof fetch | undefined}; /** * 🛡️ Stream a music track. * * GET /api/v1/music/stream/{id} * * Also accepts auth: Local User JWT */ export const getApiApiV1MusicStreamId = async (args: GetApiApiV1MusicStreamIdArgs, options: GetApiApiV1MusicStreamIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, LocalUserJWTQueryParameter} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.transcode != null) query.append("transcode", String(args.transcode)) if (args.bitrate != null) query.append("bitrate", String(args.bitrate)) if (LocalUserJWTQueryParameter !== undefined) query.set("token", LocalUserJWTQueryParameter) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/music/stream/${encodeURIComponent(String(args.id))}${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 undefined };