.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
chefkoch.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""Chefkoch is a German database of recipes.
3
"""
4
5
from
datetime
import
datetime
6
from
urllib.parse
import
urlencode
7
8
about = {
9
'website'
:
"https://www.chefkoch.de"
,
10
'official_api_documentation'
:
None
,
11
'use_official_api'
:
False
,
12
'require_api_key'
:
False
,
13
'results'
:
'JSON'
,
14
'language'
:
'de'
,
15
}
16
17
paging =
True
18
categories = []
19
20
number_of_results = 20
21
skip_premium =
True
22
23
24
base_url =
"https://api.chefkoch.de"
25
thumbnail_format =
"crop-240x300"
26
27
28
def
request
(query, params):
29
args = {
'query'
: query,
'limit'
: number_of_results,
'offset'
: (params[
'pageno'
] - 1) * number_of_results}
30
params[
'url'
] = f
"{base_url}/v2/search-gateway/recipes?{urlencode(args)}"
31
return
params
32
33
34
def
response
(resp):
35
results = []
36
37
json = resp.json()
38
39
for
result
in
json[
'results'
]:
40
recipe = result[
'recipe'
]
41
42
if
skip_premium
and
(recipe[
'isPremium'
]
or
recipe[
'isPlus'
]):
43
continue
44
45
publishedDate =
None
46
if
recipe[
'submissionDate'
]:
47
publishedDate = datetime.strptime(result[
'recipe'
][
'submissionDate'
][:19],
"%Y-%m-%dT%H:%M:%S"
)
48
49
content = [
50
f
"Schwierigkeitsstufe (1-3): {recipe['difficulty']}"
,
51
f
"Zubereitungszeit: {recipe['preparationTime']}min"
,
52
f
"Anzahl der Zutaten: {recipe['ingredientCount']}"
,
53
]
54
55
if
recipe[
'subtitle'
]:
56
content.insert(0, recipe[
'subtitle'
])
57
58
results.append(
59
{
60
'url'
: recipe[
'siteUrl'
],
61
'title'
: recipe[
'title'
],
62
'content'
:
" | "
.join(content),
63
'thumbnail'
: recipe[
'previewImageUrlTemplate'
].replace(
"<format>"
, thumbnail_format),
64
'publishedDate'
: publishedDate,
65
}
66
)
67
68
return
results
searx.engines.chefkoch.request
request(query, params)
Definition
chefkoch.py:28
searx.engines.chefkoch.response
response(resp)
Definition
chefkoch.py:34
searxng
searx
engines
chefkoch.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0