diff --git a/src/backend/metadata/tmdb.ts b/src/backend/metadata/tmdb.ts index 4c3259a3..f5d1e370 100644 --- a/src/backend/metadata/tmdb.ts +++ b/src/backend/metadata/tmdb.ts @@ -101,10 +101,13 @@ const headers = { Authorization: `Bearer ${conf().TMDB_API_KEY}`, }; -async function get(url: string): Promise { - const res = await mwFetch(url, { +async function get(url: string, params?: object): Promise { + const res = await mwFetch(encodeURI(url), { headers, baseURL, + params: { + ...params, + }, }); return res; } @@ -117,14 +120,20 @@ export async function searchMedia( switch (type) { case "movie": - data = await get( - `search/movie?query=${query}&include_adult=false&language=en-US&page=1` - ); + data = await get("search/movie", { + query, + include_adult: false, + language: "en-US", + page: 1, + }); break; case "show": - data = await get( - `search/tv?query=${query}&include_adult=false&language=en-US&page=1` - ); + data = await get("search/tv", { + query, + include_adult: false, + language: "en-US", + page: 1, + }); break; default: throw new Error("Invalid media type");