From b6fd7cd571c52924f98e907b529cbc11865aba44 Mon Sep 17 00:00:00 2001 From: ta Date: Wed, 17 Aug 2022 14:25:22 +0700 Subject: [PATCH] add thumbnail to results if available --- searx/engines/twitter.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/searx/engines/twitter.py b/searx/engines/twitter.py index d5d276e3..15d92c0e 100644 --- a/searx/engines/twitter.py +++ b/searx/engines/twitter.py @@ -46,11 +46,16 @@ def response(resp): text = tweet['full_text'] display = tweet['display_text_range'] + img_src = tweet.get('extended_entities', {}).get('media', [{}])[0].get('media_url_https') + if img_src: + img_src += "?name=thumb" + results.append( { 'url': 'https://twitter.com/i/web/status/' + tweet['id_str'], 'title': (text[:40] + '...') if len(text) > 40 else text, 'content': text[display[0] : display[1]], + 'img_src': img_src, 'publishedDate': datetime.strptime(tweet['created_at'], '%a %b %d %H:%M:%S %z %Y'), } )