export type MediaPathInfo = {Path?: (string | null) | undefined, NetworkPath?: (string | null) | undefined}; export type MediaPathDto = {Name: string, Path?: (string | null) | undefined, PathInfo?: MediaPathInfo | undefined}; export type CreateApiLibraryVirtualFoldersPathsArgs = {refreshLibrary?: boolean | undefined, body: MediaPathDto}; export type CreateApiLibraryVirtualFoldersPathsOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add a media path to a library. * * POST /Library/VirtualFolders/Paths */ export const createApiLibraryVirtualFoldersPaths = async (args: CreateApiLibraryVirtualFoldersPathsArgs, options?: CreateApiLibraryVirtualFoldersPathsOptions) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.refreshLibrary != null) query.append("refreshLibrary", String(args.refreshLibrary)) if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Library/VirtualFolders/Paths${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };