summaryrefslogtreecommitdiff
path: root/searx/engines/invidious.py
diff options
context:
space:
mode:
authorMichael Ilsaas <mikeri@mikeri.net>2020-08-02 13:31:04 +0200
committerMichael Ilsaas <mikeri@mikeri.net>2020-08-02 13:31:04 +0200
commit2ed8ad76917ec9429763d8cd5c22d20303673ca0 (patch)
treef47a98f3f3a9c26df803c33b54454bcaccc45e60 /searx/engines/invidious.py
parent0305fe0dd5a5aaad5965e87e80c6cc5a2ce0e17f (diff)
downloadsearxng-2ed8ad76917ec9429763d8cd5c22d20303673ca0.tar.gz
searxng-2ed8ad76917ec9429763d8cd5c22d20303673ca0.zip
include length in invidious results
Diffstat (limited to 'searx/engines/invidious.py')
-rw-r--r--searx/engines/invidious.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/searx/engines/invidious.py b/searx/engines/invidious.py
index e94d7c17d..cf76fd215 100644
--- a/searx/engines/invidious.py
+++ b/searx/engines/invidious.py
@@ -6,8 +6,7 @@
# @using-api yes
# @results JSON
# @stable yes
-# @parse url, title, content, publishedDate, thumbnail, embedded
-# @parse url, title, content, publishedDate, thumbnail, embedded, author
+# @parse url, title, content, publishedDate, thumbnail, embedded, author, length
from searx.url_utils import quote_plus
from dateutil import parser
@@ -85,12 +84,18 @@ def response(resp):
publishedDate = parser.parse(
time.ctime(result.get("published", 0))
)
+ length = time.gmtime(result.get("lengthSeconds"))
+ if length.tm_hour:
+ length = time.strftime("%H:%M:%S", length)
+ else:
+ length = time.strftime("%M:%S", length)
results.append(
{
"url": url,
"title": result.get("title", ""),
"content": result.get("description", ""),
+ 'length': length,
"template": "videos.html",
"author": result.get("author"),
"publishedDate": publishedDate,