export type RemoteSearchResult = {Name?: (string | null) | undefined, ProviderIds?: ({[key: string]: string} | null) | undefined, ProductionYear?: (number | null) | undefined, IndexNumber?: (number | null) | undefined, IndexNumberEnd?: (number | null) | undefined, ParentIndexNumber?: (number | null) | undefined, PremiereDate?: (string | null) | undefined, ImageUrl?: (string | null) | undefined, SearchProviderName?: (string | null) | undefined, Overview?: (string | null) | undefined, AlbumArtist?: RemoteSearchResult | undefined, Artists?: (Array | null) | undefined}; export type CreateApiItemsRemoteSearchApplyItemIdArgs = {itemId: string, replaceAllImages?: boolean | undefined, body: RemoteSearchResult}; export type CreateApiItemsRemoteSearchApplyItemIdOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Applies search criteria to an item and refreshes metadata. * * POST /Items/RemoteSearch/Apply/{itemId} */ export const createApiItemsRemoteSearchApplyItemId = async (args: CreateApiItemsRemoteSearchApplyItemIdArgs, options?: CreateApiItemsRemoteSearchApplyItemIdOptions) => { 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.replaceAllImages != null) query.append("replaceAllImages", String(args.replaceAllImages)) if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Items/RemoteSearch/Apply/${encodeURIComponent(String(args.itemId))}${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 };