mirror of
https://github.com/searxng/searxng
synced 2024-01-01 18:24:07 +00:00
[mod] improve video results of the qwant engine
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
f376b4ed3e
commit
628b5703f3
@ -29,6 +29,7 @@ from datetime import (
|
|||||||
)
|
)
|
||||||
from json import loads
|
from json import loads
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
from flask_babel import gettext
|
||||||
|
|
||||||
# from searx import logger
|
# from searx import logger
|
||||||
from searx.utils import match_language
|
from searx.utils import match_language
|
||||||
@ -100,6 +101,7 @@ def request(query, params):
|
|||||||
|
|
||||||
def response(resp):
|
def response(resp):
|
||||||
"""Get response from Qwant's search request"""
|
"""Get response from Qwant's search request"""
|
||||||
|
# pylint: disable=too-many-locals, too-many-branches, too-many-statements
|
||||||
|
|
||||||
keyword = category_to_keyword[categories[0]]
|
keyword = category_to_keyword[categories[0]]
|
||||||
results = []
|
results = []
|
||||||
@ -180,11 +182,28 @@ def response(resp):
|
|||||||
})
|
})
|
||||||
|
|
||||||
elif mainline_type == 'videos':
|
elif mainline_type == 'videos':
|
||||||
content = item['desc']
|
# some videos do not have a description: while quant-video
|
||||||
|
# returns an empty string, such video from a quant-web query
|
||||||
|
# miss the 'desc' key.
|
||||||
|
content = item.get('desc', '')
|
||||||
|
s, c = item.get('source',''), item.get('channel','')
|
||||||
|
if content and (s or c):
|
||||||
|
content += " // "
|
||||||
|
if s:
|
||||||
|
content += "%s: %s " % (gettext("Source"), s)
|
||||||
|
if c:
|
||||||
|
content += "//"
|
||||||
|
if c:
|
||||||
|
content += " %s: %s " % (gettext("Channel"), c)
|
||||||
length = timedelta(seconds=item['duration'])
|
length = timedelta(seconds=item['duration'])
|
||||||
pub_date = datetime.fromtimestamp(item['date'])
|
pub_date = datetime.fromtimestamp(item['date'])
|
||||||
thumbnail = item['thumbnail']
|
thumbnail = item['thumbnail']
|
||||||
|
# from some locations (DE and others?) the s2 link do
|
||||||
|
# response a 'Please wait ..' but does not deliver the thumbnail
|
||||||
|
thumbnail = thumbnail.replace(
|
||||||
|
'https://s2.qwant.com',
|
||||||
|
'https://s1.qwant.com', 1
|
||||||
|
)
|
||||||
results.append({
|
results.append({
|
||||||
'title': title,
|
'title': title,
|
||||||
'url': res_url,
|
'url': res_url,
|
||||||
|
Loading…
Reference in New Issue
Block a user