on master help sign in
Merge pull request #2116 from mikeri/invidiousres

Include author and video length in Invidious results

commit77103c78740169768a41587f852c73d8772c49e6 authorAdam Tauber <asciimoo@gmail.com> dateMon 10 Aug 2020, 12:49 (6 years ago) parente6d002a2ed8ad7
1 file changed+8−1
searx/engines/invidious.py+8−1
searx/engines/invidious.py+8−1
@@ -6,7 +6,7 @@
66# @using-api yes
77# @results JSON
88# @stable yes
9−# @parse url, title, content, publishedDate, thumbnail, embedded
9+# @parse url, title, content, publishedDate, thumbnail, embedded, author, length
1010
1111from searx.url_utils import quote_plus
1212from dateutil import parser
@@ -84,13 +84,20 @@ def response(resp):
8484 publishedDate = parser.parse(
8585 time.ctime(result.get("published", 0))
8686 )
87+ length = time.gmtime(result.get("lengthSeconds"))
88+ if length.tm_hour:
89+ length = time.strftime("%H:%M:%S", length)
90+ else:
91+ length = time.strftime("%M:%S", length)
8792
8893 results.append(
8994 {
9095 "url": url,
9196 "title": result.get("title", ""),
9297 "content": result.get("description", ""),
98+ 'length': length,
9399 "template": "videos.html",
100+ "author": result.get("author"),
94101 "publishedDate": publishedDate,
95102 "embedded": embedded,
96103 "thumbnail": thumbnail,