Browse Source

Merge pull request #2116 from mikeri/invidiousres

Include author and video length in Invidious results
Adam Tauber 4 years ago
parent
commit
77103c7874
1 changed files with 8 additions and 1 deletions
  1. 8 1
      searx/engines/invidious.py

+ 8 - 1
searx/engines/invidious.py

@@ -6,7 +6,7 @@
 # @using-api   yes
 # @results     JSON
 # @stable      yes
-# @parse       url, title, content, publishedDate, thumbnail, embedded
+# @parse       url, title, content, publishedDate, thumbnail, embedded, author, length
 
 from searx.url_utils import quote_plus
 from dateutil import parser
@@ -84,13 +84,20 @@ 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,
                     "embedded": embedded,
                     "thumbnail": thumbnail,