diff --git a/server/api/themoviedb.ts b/server/api/themoviedb.ts index 6f87823b6..120306b22 100644 --- a/server/api/themoviedb.ts +++ b/server/api/themoviedb.ts @@ -1,4 +1,5 @@ import axios, { AxiosInstance } from 'axios'; +import logger from '../logger'; export const ANIME_KEYWORD_ID = 210024; @@ -374,7 +375,16 @@ class TheMovieDb { return response.data; } catch (e) { - throw new Error(`[TMDB] Failed to search multi: ${e.message}`); + logger.error('Failed to search multi', { + label: 'TMDB', + errorMessage: e.message, + }); + return { + page: 1, + results: [], + total_pages: 1, + total_results: 0, + }; } }; diff --git a/src/hooks/useSearchInput.ts b/src/hooks/useSearchInput.ts index b761928dd..21cfd9831 100644 --- a/src/hooks/useSearchInput.ts +++ b/src/hooks/useSearchInput.ts @@ -7,8 +7,20 @@ import type { Nullable } from '../utils/typeHelpers'; type Url = string | UrlObject; +const extraEncodes: [RegExp, string][] = [ + [/\(/g, '%28'], + [/\)/g, '%29'], + [/!/g, '%21'], +]; + const encodeURIExtraParams = (string: string): string => { - return encodeURIComponent(string).replace(/!/g, '%21'); + let finalString = encodeURIComponent(string); + + extraEncodes.forEach((encode) => { + finalString = finalString.replace(encode[0], encode[1]); + }); + + return finalString; }; interface SearchObject {