.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
findthatmeme.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""FindThatMeme (Images)"""
3
4from json import dumps
5from datetime import datetime
6from searx.utils import humanize_bytes
7
8about = {
9 "website": 'https://findthatmeme.com',
10 "official_api_documentation": None,
11 "use_official_api": False,
12 "require_api_key": False,
13 "results": "JSON",
14}
15
16base_url = "https://findthatmeme.com/api/v1/search"
17categories = ['images']
18paging = True
19
20
21def request(query, params):
22
23 start_index = (params["pageno"] - 1) * 50
24 data = {"search": query, "offset": start_index}
25 params["url"] = base_url
26 params["method"] = 'POST'
27 params['headers']['content-type'] = "application/json"
28 params['data'] = dumps(data)
29
30 return params
31
32
33def response(resp):
34 search_res = resp.json()
35 results = []
36
37 for item in search_res:
38 img = 'https://findthatmeme.us-southeast-1.linodeobjects.com/' + item['image_path']
39 thumb = 'https://findthatmeme.us-southeast-1.linodeobjects.com/thumb/' + item.get('thumbnail', '')
40 date = datetime.strptime(item["updated_at"].split("T")[0], "%Y-%m-%d")
41 formatted_date = datetime.utcfromtimestamp(date.timestamp())
42
43 results.append(
44 {
45 'url': item['source_page_url'],
46 'title': item['source_site'],
47 'img_src': img if item['type'] == 'IMAGE' else thumb,
48 'filesize': humanize_bytes(item['meme_file_size']),
49 'publishedDate': formatted_date,
50 'template': 'images.html',
51 }
52 )
53
54 return results