export type GetApiV1VideosIdCaptionsArgs = {id: string, format?: ('srt' | 'vtt') | undefined, lang?: string | undefined}; export type GetApiV1VideosIdCaptionsOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download video captions * * GET /v1/videos/{id}/captions */ export const getApiV1VideosIdCaptions = async (args: GetApiV1VideosIdCaptionsArgs, options?: GetApiV1VideosIdCaptionsOptions) => { const {baseUrl = "https://api.tella.com", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/x-subrip") if (args.format != null) query.append("format", String(args.format)) if (args.lang != null) query.append("lang", String(args.lang)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/videos/${encodeURIComponent(String(args.id))}/captions${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() };