summaryrefslogtreecommitdiff
path: root/searx/engines/wallhaven.py
diff options
context:
space:
mode:
authorBnyro <bnyro@tutanota.com>2024-02-20 10:51:58 +0100
committerMarkus Heiser <markus.heiser@darmarIT.de>2024-02-25 16:22:37 +0100
commite76ab1a4b3a99b0ec2ef90c3aadc92ffbf6889b1 (patch)
treebe5443686fbe1ab6a6fa95e55a12a189230ba92e /searx/engines/wallhaven.py
parentb683aa63fb3e1689c28bd4b762b4ad962e8e232c (diff)
downloadsearxng-e76ab1a4b3a99b0ec2ef90c3aadc92ffbf6889b1.tar.gz
searxng-e76ab1a4b3a99b0ec2ef90c3aadc92ffbf6889b1.zip
[refactor] images: add resolution, image format and filesize fields
Co-authored-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/wallhaven.py')
-rw-r--r--searx/engines/wallhaven.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/searx/engines/wallhaven.py b/searx/engines/wallhaven.py
index f80b5d86d..94be1a6a7 100644
--- a/searx/engines/wallhaven.py
+++ b/searx/engines/wallhaven.py
@@ -8,6 +8,8 @@
from datetime import datetime
from urllib.parse import urlencode
+from searx.utils import humanize_bytes
+
about = {
'website': 'https://wallhaven.cc/',
'official_api_documentation': 'https://wallhaven.cc/help/api',
@@ -68,6 +70,7 @@ def response(resp):
json = resp.json()
for result in json['data']:
+
results.append(
{
'template': 'images.html',
@@ -76,8 +79,10 @@ def response(resp):
'url': result['url'],
'img_src': result['path'],
'thumbnail_src': result['thumbs']['small'],
- 'img_format': result['resolution'],
+ 'resolution': result['resolution'].replace('x', ' x '),
'publishedDate': datetime.strptime(result['created_at'], '%Y-%m-%d %H:%M:%S'),
+ 'img_format': result['file_type'],
+ 'filesize': humanize_bytes(result['file_size']),
}
)