export type GetApiVideosItemIdMediaSourceIdSubtitlesIndexSubtitlesM3u8Args = {itemId: string, index: number, mediaSourceId: string, segmentLength: number}; export type GetApiVideosItemIdMediaSourceIdSubtitlesIndexSubtitlesM3u8Options = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Gets an HLS subtitle playlist. * * GET /Videos/{itemId}/{mediaSourceId}/Subtitles/{index}/subtitles.m3u8 */ export const getApiVideosItemIdMediaSourceIdSubtitlesIndexSubtitlesM3u8 = async (args: GetApiVideosItemIdMediaSourceIdSubtitlesIndexSubtitlesM3u8Args, options?: GetApiVideosItemIdMediaSourceIdSubtitlesIndexSubtitlesM3u8Options) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/x-mpegURL") if (args.segmentLength != null) query.append("segmentLength", String(args.segmentLength)) if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Videos/${encodeURIComponent(String(args.itemId))}/${encodeURIComponent(String(args.mediaSourceId))}/Subtitles/${encodeURIComponent(String(args.index))}/subtitles.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() };