[fix] follow-up of 4da7003ae / add missing review from @Bnyro

[1] https://github.com/searxng/searxng/pull/2656#pullrequestreview-1607956209

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2023-09-02 09:26:45 +02:00
parent 4da7003ae0
commit 4f8895c6de
1 changed files with 5 additions and 7 deletions

View File

@ -6,6 +6,7 @@
"""
import time
from urllib.parse import urlencode
from datetime import datetime
# Engine metadata
@ -21,16 +22,14 @@ about = {
# Engine configuration
paging = True
results_per_page = 20
categories = ['images']
categories = ['videos']
# Search URL (Note: lighthouse.lbry.com/search works too, and may be faster at times)
base_url = "https://lighthouse.odysee.tv/search"
# Request function
def request(query, params):
page = params.get("pageno", 1) - 1
start_index = page * results_per_page
def request(query, params):
start_index = (params["pageno"] - 1) * results_per_page
query_params = {
"s": query,
"size": results_per_page,
@ -39,8 +38,7 @@ def request(query, params):
"mediaType": "video",
}
query_str = "&".join([f"{key}={value}" for key, value in query_params.items()])
params["url"] = f"{base_url}?{query_str}"
params["url"] = f"{base_url}?{urlencode(query_params)}"
return params