summaryrefslogtreecommitdiff
path: root/searx/engines
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-07-16 15:33:56 +0200
committerGitHub <noreply@github.com>2021-07-16 15:33:56 +0200
commit8237cb557e1d4a59e9c64128f50cc95ceca518ba (patch)
tree29b0ed1258e15c6e4ecde85b4c8f6791d06ada90 /searx/engines
parent1ba3e5afa02503981182aeb3a76e3826093a381a (diff)
parent0d65a81b1c31383a0c24a4368612e959dbd17438 (diff)
downloadsearxng-8237cb557e1d4a59e9c64128f50cc95ceca518ba.tar.gz
searxng-8237cb557e1d4a59e9c64128f50cc95ceca518ba.zip
Merge pull request #206 from return42/improve-qwant
[mod] improve video results of the qwant engine
Diffstat (limited to 'searx/engines')
-rw-r--r--searx/engines/qwant.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py
index 00ecf7e83..97e461177 100644
--- a/searx/engines/qwant.py
+++ b/searx/engines/qwant.py
@@ -29,13 +29,12 @@ from datetime import (
)
from json import loads
from urllib.parse import urlencode
+from flask_babel import gettext
-# from searx import logger
from searx.utils import match_language
from searx.exceptions import SearxEngineAPIException
from searx.network import raise_for_httperror
-#logger = logger.getChild('qwant')
# about
about = {
@@ -100,6 +99,7 @@ def request(query, params):
def response(resp):
"""Get response from Qwant's search request"""
+ # pylint: disable=too-many-locals, too-many-branches, too-many-statements
keyword = category_to_keyword[categories[0]]
results = []
@@ -180,11 +180,27 @@ def response(resp):
})
elif mainline_type == 'videos':
- content = item['desc']
+ # some videos do not have a description: while qwant-video
+ # returns an empty string, such video from a qwant-web query
+ # miss the 'desc' key.
+ d, s, c = item.get('desc'), item.get('source'), item.get('channel')
+ content_parts = []
+ if d:
+ content_parts.append(d)
+ if s:
+ content_parts.append("%s: %s " % (gettext("Source"), s))
+ if c:
+ content_parts.append("%s: %s " % (gettext("Channel"), c))
+ content = ' // '.join(content_parts)
length = timedelta(seconds=item['duration'])
pub_date = datetime.fromtimestamp(item['date'])
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({
'title': title,
'url': res_url,