Tmdb search w/ adult and media type filters.

Adult is set to disable filtering adult material for search results.
Media type checks if movie, show or person and appends type to url path
for searches by type only. E.g. mediaType = 'show' ->
api/v1/search/show?query=Friends.
This commit is contained in:
2019-12-26 01:59:01 +01:00
parent 582207d453
commit 0d57e9a03b

View File

@@ -128,10 +128,15 @@ const getUserRequests = (page=1) => {
* @param {number} [page=1]
* @returns {object} Tmdb response
*/
const searchTmdb = (query, page=1) => {
const searchTmdb = (query, page=1, adult=false, mediaType=null) => {
const url = new URL('v2/search', SEASONED_URL)
if (mediaType != null && ['movie', 'show', 'person'].includes(mediaType)) {
url.pathname += `/${mediaType}`
}
url.searchParams.append('query', query)
url.searchParams.append('page', page)
url.searchParams.append('adult', adult)
const headers = { authorization: localStorage.getItem('token') }