mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
d
This commit is contained in:
parent
4a74bca137
commit
b081ec0118
3 changed files with 36 additions and 8 deletions
28
searx/engines/tmdb.py
Normal file
28
searx/engines/tmdb.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
from json import loads
|
||||
from urllib.parse import urlencode
|
||||
SEARCH_URL = "https://api.themoviedb.org/3/search/multi"
|
||||
API_KEY = "f6bd687ffa63cd282b6ff2c6877f2669"
|
||||
|
||||
def request(query, params):
|
||||
params["url"] = SEARCH_URL + "?api_key=" + API_KEY + "&query=" + urlencode(query)
|
||||
language = params.get("language")
|
||||
if language:
|
||||
params["url"] += "&language=" + language
|
||||
pageno = params.get("pageno")
|
||||
if pageno:
|
||||
params["url"] += "&page=" + str(pageno)
|
||||
return params
|
||||
|
||||
def response(resp):
|
||||
results = []
|
||||
data = loads(resp.text)["results"]
|
||||
if data:
|
||||
for item in data:
|
||||
result = {
|
||||
"title": item.get("name"),
|
||||
"url": f"https://www.themoviedb.org/{item.get('media_type')}/{item.get('id')}",
|
||||
"content": item.get("overview"),
|
||||
"publishedDate": item.get("release_date") or item.get("first_air_date"),
|
||||
}
|
||||
results.append(result)
|
||||
return results
|
|
@ -114,13 +114,13 @@ def response(resp):
|
|||
if not result_chunks:
|
||||
return []
|
||||
|
||||
results.append(
|
||||
{
|
||||
'infobox': infobox_title,
|
||||
'attributes': result_chunks,
|
||||
'urls': [{'title': 'WolframAlpha', 'url': resp.request.headers['Referer']}],
|
||||
}
|
||||
)
|
||||
# results.append(
|
||||
# {
|
||||
# 'infobox': infobox_title,
|
||||
# 'attributes': result_chunks,
|
||||
# 'urls': [{'title': 'WolframAlpha', 'url': resp.request.headers['Referer']}],
|
||||
# }
|
||||
# )
|
||||
|
||||
results.append(
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue