.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
4
from
json
import
dumps
5
from
datetime
import
datetime
6
from
searx.utils
import
humanize_bytes
7
8
about = {
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
16
base_url =
"https://findthatmeme.com/api/v1/search"
17
categories = [
'images'
]
18
paging =
True
19
20
21
def
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
33
def
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
searx.engines.findthatmeme.response
response(resp)
Definition
findthatmeme.py:33
searx.engines.findthatmeme.request
request(query, params)
Definition
findthatmeme.py:21
searx.utils
Definition
utils.py:1
searxng
searx
engines
findthatmeme.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0