diff --git a/searx/engines/invidious.py b/searx/engines/invidious.py index 49f90cc09..540f89a2f 100644 --- a/searx/engines/invidious.py +++ b/searx/engines/invidious.py @@ -7,6 +7,8 @@ import random from urllib.parse import quote_plus, urlparse from dateutil import parser +from searx.utils import humanize_number + # about about = { "website": 'https://api.invidious.io/', @@ -91,7 +93,8 @@ def response(resp): "url": url, "title": result.get("title", ""), "content": result.get("description", ""), - 'length': length, + "length": length, + "views": humanize_number(result['viewCount']), "template": "videos.html", "author": result.get("author"), "publishedDate": publishedDate, diff --git a/searx/engines/peertube.py b/searx/engines/peertube.py index 114e24c4f..0457c5d8d 100644 --- a/searx/engines/peertube.py +++ b/searx/engines/peertube.py @@ -14,7 +14,7 @@ import babel from searx.network import get # see https://github.com/searxng/searxng/issues/762 from searx.locales import language_tag -from searx.utils import html_to_text +from searx.utils import html_to_text, humanize_number from searx.enginelib.traits import EngineTraits traits: EngineTraits @@ -124,6 +124,7 @@ def video_response(resp): 'content': html_to_text(result.get('description') or ''), 'author': result.get('account', {}).get('displayName'), 'length': minute_to_hm(result.get('duration')), + 'views': humanize_number(result['views']), 'template': 'videos.html', 'publishedDate': parse(result['publishedAt']), 'iframe_src': result.get('embedUrl'), diff --git a/searx/engines/piped.py b/searx/engines/piped.py index 5b60dec5a..0b7199437 100644 --- a/searx/engines/piped.py +++ b/searx/engines/piped.py @@ -53,6 +53,8 @@ from urllib.parse import urlencode import datetime from dateutil import parser +from searx.utils import humanize_number + # about about = { "website": 'https://github.com/TeamPiped/Piped/', @@ -138,6 +140,7 @@ def response(resp): "title": result.get("title", ""), "publishedDate": parser.parse(time.ctime(uploaded / 1000)) if uploaded != -1 else None, "iframe_src": _frontend_url() + '/embed' + result.get("url", ""), + "views": humanize_number(result["views"]), } length = result.get("duration") if length: diff --git a/searx/static/themes/simple/src/less/style.less b/searx/static/themes/simple/src/less/style.less index 0d0996e7b..b7cd475f7 100644 --- a/searx/static/themes/simple/src/less/style.less +++ b/searx/static/themes/simple/src/less/style.less @@ -271,6 +271,7 @@ article[data-vim-selected].category-social { .published_date, .result_length, + .result_views, .result_author, .result_shipping, .result_source_country { diff --git a/searx/templates/simple/macros.html b/searx/templates/simple/macros.html index 9ec6fb47c..f7af553b6 100644 --- a/searx/templates/simple/macros.html +++ b/searx/templates/simple/macros.html @@ -33,6 +33,7 @@ {%- macro result_sub_header(result) -%} {%- if result.publishedDate %}{% endif -%} {%- if result.length %}