summaryrefslogtreecommitdiff
path: root/searx/engines/findthatmeme.py
diff options
context:
space:
mode:
authorAustin-Olacsi <138650713+Austin-Olacsi@users.noreply.github.com>2024-05-26 23:57:38 -0600
committerMarkus Heiser <markus.heiser@darmarIT.de>2024-05-28 18:18:13 +0200
commit9bb75a66449c00e3efeb2c2ecedb0b5ee4ec70ee (patch)
tree85d9962345156df1eae2b84d0b80335c38a1b3a9 /searx/engines/findthatmeme.py
parente992e888a0226a8edaf1604fb91e49496627c136 (diff)
downloadsearxng-9bb75a66449c00e3efeb2c2ecedb0b5ee4ec70ee.tar.gz
searxng-9bb75a66449c00e3efeb2c2ecedb0b5ee4ec70ee.zip
[feat] engine: implementation of findthatmeme
Diffstat (limited to 'searx/engines/findthatmeme.py')
-rw-r--r--searx/engines/findthatmeme.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/searx/engines/findthatmeme.py b/searx/engines/findthatmeme.py
new file mode 100644
index 000000000..e52996d69
--- /dev/null
+++ b/searx/engines/findthatmeme.py
@@ -0,0 +1,54 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+"""FindThatMeme (Images)"""
+
+from json import dumps
+from datetime import datetime
+from searx.utils import humanize_bytes
+
+about = {
+ "website": 'https://findthatmeme.com',
+ "official_api_documentation": None,
+ "use_official_api": False,
+ "require_api_key": False,
+ "results": "JSON",
+}
+
+base_url = "https://findthatmeme.com/api/v1/search"
+categories = ['images']
+paging = True
+
+
+def request(query, params):
+
+ start_index = (params["pageno"] - 1) * 50
+ data = {"search": query, "offset": start_index}
+ params["url"] = base_url
+ params["method"] = 'POST'
+ params['headers']['content-type'] = "application/json"
+ params['data'] = dumps(data)
+
+ return params
+
+
+def response(resp):
+ search_res = resp.json()
+ results = []
+
+ for item in search_res:
+ img = 'https://findthatmeme.us-southeast-1.linodeobjects.com/' + item['image_path']
+ thumb = 'https://findthatmeme.us-southeast-1.linodeobjects.com/thumb/' + item.get('thumbnail', '')
+ date = datetime.strptime(item["updated_at"].split("T")[0], "%Y-%m-%d")
+ formatted_date = datetime.utcfromtimestamp(date.timestamp())
+
+ results.append(
+ {
+ 'url': item['source_page_url'],
+ 'title': item['source_site'],
+ 'img_src': img if item['type'] == 'IMAGE' else thumb,
+ 'filesize': humanize_bytes(item['meme_file_size']),
+ 'publishedDate': formatted_date,
+ 'template': 'images.html',
+ }
+ )
+
+ return results