export type GetApiVideosItemIdHlsPlaylistIdStreamM3u8Args = {itemId: string, playlistId: string}; export type GetApiVideosItemIdHlsPlaylistIdStreamM3u8Options = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Gets a hls video playlist. * * GET /Videos/{itemId}/hls/{playlistId}/stream.m3u8 */ export const getApiVideosItemIdHlsPlaylistIdStreamM3u8 = async (args: GetApiVideosItemIdHlsPlaylistIdStreamM3u8Args, options?: GetApiVideosItemIdHlsPlaylistIdStreamM3u8Options) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/x-mpegURL") if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Videos/${encodeURIComponent(String(args.itemId))}/hls/${encodeURIComponent(String(args.playlistId))}/stream.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() };