.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
yummly.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""Yummly
3
"""
4
5
from
urllib.parse
import
urlencode
6
7
from
flask_babel
import
gettext
8
from
searx.utils
import
markdown_to_text
9
10
about = {
11
"website"
:
'https://yummly.com'
,
12
"wikidata_id"
:
'Q8061140'
,
13
# not used since it requires an api key
14
"official_api_documentation"
:
'https://developer.yummly.com/documentation.html'
,
15
"use_official_api"
:
False
,
16
"require_api_key"
:
False
,
17
"results"
:
'JSON'
,
18
}
19
paging =
True
20
categories = []
21
22
api_url =
"https://mapi.yummly.com"
23
number_of_results = 10
24
show_pro_recipes =
False
25
base_url =
"https://www.yummly.com"
26
27
28
def
request
(query, params):
29
args = {
30
'q'
: query,
31
'start'
: (params[
'pageno'
] - 1) * number_of_results,
32
'maxResult'
: number_of_results,
33
}
34
35
params[
'url'
] = f
"{api_url}/mapi/v23/content/search?{urlencode(args)}&allowedContent=single_recipe"
36
37
return
params
38
39
40
def
response
(resp):
41
results = []
42
43
json = resp.json()
44
45
for
result
in
json[
'feed'
]:
46
# don't show pro recipes since they can't be accessed without an account
47
if
not
show_pro_recipes
and
result[
'proRecipe'
]:
48
continue
49
50
content = result[
'seo'
][
'web'
][
'meta-tags'
][
'description'
]
51
description = result[
'content'
][
'description'
]
52
if
description
is
not
None
:
53
content = markdown_to_text(description[
'text'
])
54
55
thumbnail =
None
56
if
result[
'display'
][
'images'
]:
57
thumbnail = result[
'display'
][
'images'
][0]
58
elif
result[
'content'
][
'details'
][
'images'
]:
59
thumbnail = result[
'content'
][
'details'
][
'images'
][0][
'resizableImageUrl'
]
60
61
url = result[
'display'
][
'source'
][
'sourceRecipeUrl'
]
62
if
'www.yummly.com/private'
in
url:
63
url = base_url +
'/'
+ result[
'tracking-id'
]
64
65
results.append(
66
{
67
'url'
: url,
68
'title'
: result[
'display'
][
'displayName'
],
69
'content'
: content,
70
'thumbnail'
: thumbnail,
71
'metadata'
: gettext(
'Language'
) + f
": {result['locale'].split('-')[0]}"
,
72
}
73
)
74
75
for
suggestion
in
json[
'relatedPhrases'
][
'keywords'
]:
76
results.append({
'suggestion'
: suggestion})
77
78
return
results
searx.engines.yummly.request
request(query, params)
Definition
yummly.py:28
searx.engines.yummly.response
response(resp)
Definition
yummly.py:40
searx.utils
Definition
utils.py:1
searxng
searx
engines
yummly.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0