mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-05-26 12:32:25 +00:00
Implement video filters
This commit is contained in:
parent
aa953dc796
commit
db7ccabb3b
19 changed files with 790 additions and 9 deletions
|
|
@ -7,10 +7,14 @@ module.exports = [
|
|||
{
|
||||
route: "/(?:search|results)", methods: ["GET"], code: async ({req, url}) => {
|
||||
const query = url.searchParams.get("q") || url.searchParams.get("search_query")
|
||||
const instanceOrigin = getUser(req).getSettingsOrDefaults().instance
|
||||
const user = getUser(req)
|
||||
const settings = user.getSettingsOrDefaults()
|
||||
const instanceOrigin = settings.instance
|
||||
|
||||
const fetchURL = new URL(`${instanceOrigin}/api/v1/search`)
|
||||
fetchURL.searchParams.set("q", query)
|
||||
const results = await request(fetchURL.toString()).then(res => res.json())
|
||||
|
||||
let results = await request(fetchURL.toString()).then(res => res.json())
|
||||
const error = results.error || results.message || results.code
|
||||
|
||||
if (error) throw new Error(`Instance said: ${error}`)
|
||||
|
|
@ -19,6 +23,9 @@ module.exports = [
|
|||
converters.normaliseVideoInfo(video)
|
||||
}
|
||||
|
||||
const filters = user.getFilters()
|
||||
results = converters.applyVideoFilters(results, filters).videos
|
||||
|
||||
return render(200, "pug/search.pug", {query, results, instanceOrigin})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue