.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.material_icons Namespace Reference

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
str search_url = "https://fonts.google.com/metadata/icons?key=material_symbols&incomplete=true"
 
str result_url = "https://fonts.google.com/icons?icon.query={query}&selected=Material+Symbols+Outlined:{icon_name}:FILL@0{fill};wght@400;GRAD@0;opsz@24"
 
str img_src_url = "https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/{icon_name}/{svg_type}/24px.svg"
 
str filled_regex = r"(fill)(ed)?"
 

Detailed Description

Material Icons (images)

Function Documentation

◆ request()

searx.engines.material_icons.request ( query,
params )

Definition at line 23 of file material_icons.py.

23def request(query, params):
24 params['url'] = search_url
25 params['query'] = query
26 return params
27
28

◆ response()

searx.engines.material_icons.response ( resp)

Definition at line 29 of file material_icons.py.

29def response(resp):
30 results = []
31
32 query = resp.search_params["query"].lower()
33 json_results = loads(resp.text[5:])
34
35 outlined = not re.findall(filled_regex, query)
36 query = re.sub(filled_regex, "", query).strip()
37 svg_type = "fill1" if not outlined else "default"
38
39 query_parts = query.split(" ")
40
41 for result in json_results["icons"]:
42 for part in query_parts:
43 if part in result["name"] or part in result["tags"] or part in result["categories"]:
44 break
45 else:
46 continue
47
48 tags = [tag.title() for tag in result["tags"]]
49 categories = [category.title() for category in result["categories"]]
50
51 results.append(
52 {
53 'template': 'images.html',
54 'url': result_url.format(icon_name=result["name"], query=result["name"], fill=0 if outlined else 1),
55 'img_src': img_src_url.format(icon_name=result["name"], svg_type=svg_type),
56 'title': result["name"].replace("_", "").title(),
57 'content': ", ".join(tags) + " / " + ", ".join(categories),
58 }
59 )
60
61 return results

Variable Documentation

◆ about

dict searx.engines.material_icons.about
Initial value:
1= {
2 "website": 'https://fonts.google.com/icons',
3 "wikidata_id": 'Q107315222',
4 "official_api_documentation": None,
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": 'JSON',
8}

Definition at line 9 of file material_icons.py.

◆ filled_regex

str searx.engines.material_icons.filled_regex = r"(fill)(ed)?"

Definition at line 20 of file material_icons.py.

◆ img_src_url

str searx.engines.material_icons.img_src_url = "https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/{icon_name}/{svg_type}/24px.svg"

Definition at line 19 of file material_icons.py.

◆ result_url

str searx.engines.material_icons.result_url = "https://fonts.google.com/icons?icon.query={query}&selected=Material+Symbols+Outlined:{icon_name}:FILL@0{fill};wght@400;GRAD@0;opsz@24"

Definition at line 18 of file material_icons.py.

◆ search_url

str searx.engines.material_icons.search_url = "https://fonts.google.com/metadata/icons?key=material_symbols&incomplete=true"

Definition at line 17 of file material_icons.py.