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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['images']
 
bool paging = True
 
str base_url = "https://wallhaven.cc"
 
str api_key = ''
 
dict safesearch_map = {0: '111', 1: '110', 2: '100'}
 

Detailed Description

Wallhaven_ is a site created by and for people who like wallpapers.

.. _Wallhaven: https://wallhaven.cc/about#Copyright

Function Documentation

◆ request()

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

Definition at line 52 of file wallhaven.py.

52def request(query, params):
53 args = {
54 'q': query,
55 'page': params['pageno'],
56 'purity': safesearch_map[params['safesearch']],
57 }
58
59 if api_key:
60 params['api_key'] = api_key
61
62 params['url'] = f"{base_url}/api/v1/search?{urlencode(args)}"
63 return params
64
65

◆ response()

searx.engines.wallhaven.response ( resp)

Definition at line 66 of file wallhaven.py.

66def response(resp):
67 results = []
68
69 json = resp.json()
70
71 for result in json['data']:
72
73 results.append(
74 {
75 'template': 'images.html',
76 'title': '',
77 'content': f"{result['category']} / {result['purity']}",
78 'url': result['url'],
79 'img_src': result['path'],
80 'thumbnail_src': result['thumbs']['small'],
81 'resolution': result['resolution'].replace('x', ' x '),
82 'publishedDate': datetime.strptime(result['created_at'], '%Y-%m-%d %H:%M:%S'),
83 'img_format': result['file_type'],
84 'filesize': humanize_bytes(result['file_size']),
85 }
86 )
87
88 return results

Variable Documentation

◆ about

dict searx.engines.wallhaven.about
Initial value:
1= {
2 'website': 'https://wallhaven.cc/',
3 'official_api_documentation': 'https://wallhaven.cc/help/api',
4 'use_official_api': True,
5 'require_api_key': False,
6 'results': 'JSON',
7}

Definition at line 12 of file wallhaven.py.

◆ api_key

str searx.engines.wallhaven.api_key = ''

Definition at line 24 of file wallhaven.py.

◆ base_url

str searx.engines.wallhaven.base_url = "https://wallhaven.cc"

Definition at line 22 of file wallhaven.py.

◆ categories

list searx.engines.wallhaven.categories = ['images']

Definition at line 19 of file wallhaven.py.

◆ paging

bool searx.engines.wallhaven.paging = True

Definition at line 20 of file wallhaven.py.

◆ safesearch_map

dict searx.engines.wallhaven.safesearch_map = {0: '111', 1: '110', 2: '100'}

Definition at line 33 of file wallhaven.py.