diff options
author | ta <alt3753.7@gmail.com> | 2022-08-24 18:33:11 +0700 |
---|---|---|
committer | ta <alt3753.7@gmail.com> | 2022-08-24 18:33:11 +0700 |
commit | cef7bbab228173db6f3a68a28b57e5dc241b9982 (patch) | |
tree | 7d9804f554415b2df8bb7a5c9392531eb750652a /searx | |
parent | 040e24f9adfdc13e70ba21271dee2b6edfd866c7 (diff) |
get the not cropped version of the thumbnail when the image height is not too important
Diffstat (limited to 'searx')
-rw-r--r-- | searx/engines/9gag.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/searx/engines/9gag.py b/searx/engines/9gag.py index 5c0f54c2..d1846725 100644 --- a/searx/engines/9gag.py +++ b/searx/engines/9gag.py @@ -39,6 +39,12 @@ def response(resp): for result in json_results['posts']: result_type = result['type'] + # Get the not cropped version of the thumbnail when the image height is not too important + if result['images']['image700']['height'] > 400: + thumbnail = result['images']['imageFbThumbnail']['url'] + else: + thumbnail = result['images']['image700']['url'] + if result_type == 'Photo': results.append( { @@ -48,7 +54,7 @@ def response(resp): 'content': result['description'], 'publishedDate': datetime.utcfromtimestamp(result['creationTs']), 'img_src': result['images']['image700']['url'], - 'thumbnail_src': result['images']['imageFbThumbnail']['url'], + 'thumbnail_src': thumbnail, } ) elif result_type == 'Animated': @@ -59,7 +65,7 @@ def response(resp): 'title': result['title'], 'content': result['description'], 'publishedDate': datetime.utcfromtimestamp(result['creationTs']), - 'thumbnail': result['images']['imageFbThumbnail']['url'], + 'thumbnail': thumbnail, 'iframe_src': result['images'].get('image460sv', {}).get('url'), } ) |