From 628b5703f3aeeed117772696f83efb344d6f337e Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 15 Jul 2021 20:10:37 +0200 Subject: [PATCH 1/2] [mod] improve video results of the qwant engine Signed-off-by: Markus Heiser --- searx/engines/qwant.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py index 00ecf7e83..00b30f4dc 100644 --- a/searx/engines/qwant.py +++ b/searx/engines/qwant.py @@ -29,6 +29,7 @@ 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 @@ -100,6 +101,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 +182,28 @@ def response(resp): }) 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']) 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, From 0d65a81b1c31383a0c24a4368612e959dbd17438 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Fri, 16 Jul 2021 15:32:12 +0200 Subject: [PATCH 2/2] [mod] qwant engine: fix typos / minor change minor modification of commit 628b5703f3aeeed117772696f83efb344d6f337e (no functionnal change) --- searx/engines/qwant.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py index 00b30f4dc..97e461177 100644 --- a/searx/engines/qwant.py +++ b/searx/engines/qwant.py @@ -31,12 +31,10 @@ 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 = { @@ -182,19 +180,18 @@ def response(resp): }) elif mainline_type == 'videos': - # some videos do not have a description: while quant-video - # returns an empty string, such video from a quant-web query + # 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. - content = item.get('desc', '') - s, c = item.get('source',''), item.get('channel','') - if content and (s or c): - content += " // " + d, s, c = item.get('desc'), item.get('source'), item.get('channel') + content_parts = [] + if d: + content_parts.append(d) if s: - content += "%s: %s " % (gettext("Source"), s) - if c: - content += "//" + content_parts.append("%s: %s " % (gettext("Source"), s)) if c: - content += " %s: %s " % (gettext("Channel"), 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']