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

Functions

 request (query, params)
 _image_result (result)
 _video_result (result)
 response (resp)

Variables

dict about
str base_url = 'https://pixabay.com'
list categories = ['images']
str pixabay_type = "images"
bool paging = True
bool safesearch = True
bool time_range_support = True
dict safesearch_map = {0: 'off', 1: '1', 2: '1'}
dict time_range_map = {'day': '1d', 'week': '1w', 'month': '1m', 'year': '1y'}
bool enable_http2 = False

Detailed Description

Pixabay provides royalty-free media (images, videos)

Function Documentation

◆ _image_result()

searx.engines.pixabay._image_result ( result)
protected

Definition at line 56 of file pixabay.py.

56def _image_result(result):
57 return {
58 'template': 'images.html',
59 'url': base_url + result["href"],
60 # images are sorted in ascending quality
61 'thumbnail_src': list(result['sources'].values())[0],
62 'img_src': list(result['sources'].values())[-1],
63 'title': result.get('name'),
64 'content': result.get('description', ''),
65 }
66
67

Referenced by response().

Here is the caller graph for this function:

◆ _video_result()

searx.engines.pixabay._video_result ( result)
protected

Definition at line 68 of file pixabay.py.

68def _video_result(result):
69 return {
70 'template': 'videos.html',
71 'url': base_url + result["href"],
72 # images are sorted in ascending quality
73 'thumbnail': result['sources'].get('thumbnail'),
74 'iframe_src': result['sources'].get('embed'),
75 'title': result.get('name'),
76 'content': result.get('description', ''),
77 'length': timedelta(seconds=result['duration']),
78 'publishedDate': parser.parse(result['uploadDate']),
79 }
80
81

Referenced by response().

Here is the caller graph for this function:

◆ request()

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

Definition at line 34 of file pixabay.py.

34def request(query, params):
35 args = {
36 'pagi': params['pageno'],
37 }
38 if params['time_range']:
39 args['date'] = time_range_map[params['time_range']]
40
41 params['url'] = f"{base_url}/{pixabay_type}/search/{quote_plus(query)}/?{urlencode(args)}"
42 params['headers'] = {
43 'User-Agent': gen_useragent() + " Pixabay",
44 'Accept': 'application/json',
45 'x-bootstrap-cache-miss': '1',
46 'x-fetch-bootstrap': '1',
47 }
48 params['cookies']['g_rated'] = safesearch_map[params['safesearch']]
49
50 # prevent automatic redirects to first page on pagination
51 params['allow_redirects'] = False
52
53 return params
54
55

◆ response()

searx.engines.pixabay.response ( resp)

Definition at line 82 of file pixabay.py.

82def response(resp):
83 results = []
84
85 # if there are no results on this page, we get a redirect
86 # to the first page
87 if resp.status_code == 302:
88 return results
89
90 json_data = resp.json()
91
92 for result in json_data.get('page', {}).get('results', []):
93 if result['mediaType'] in ('photo', 'illustration', 'vector'):
94 results.append(_image_result(result))
95 elif result['mediaType'] == 'video':
96 results.append(_video_result(result))
97
98 return results

References _image_result(), and _video_result().

Here is the call graph for this function:

Variable Documentation

◆ about

dict searx.engines.pixabay.about
Initial value:
1= {
2 "website": 'https://pixabay.com',
3 "wikidata_id": 'Q1746538',
4 "official_api_documentation": 'https://pixabay.com/api/docs/',
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": 'JSON',
8}

Definition at line 10 of file pixabay.py.

◆ base_url

str searx.engines.pixabay.base_url = 'https://pixabay.com'

Definition at line 19 of file pixabay.py.

◆ categories

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

Definition at line 20 of file pixabay.py.

◆ enable_http2

bool searx.engines.pixabay.enable_http2 = False

Definition at line 31 of file pixabay.py.

◆ paging

bool searx.engines.pixabay.paging = True

Definition at line 23 of file pixabay.py.

◆ pixabay_type

str searx.engines.pixabay.pixabay_type = "images"

Definition at line 21 of file pixabay.py.

◆ safesearch

bool searx.engines.pixabay.safesearch = True

Definition at line 24 of file pixabay.py.

◆ safesearch_map

dict searx.engines.pixabay.safesearch_map = {0: 'off', 1: '1', 2: '1'}

Definition at line 27 of file pixabay.py.

◆ time_range_map

dict searx.engines.pixabay.time_range_map = {'day': '1d', 'week': '1w', 'month': '1m', 'year': '1y'}

Definition at line 28 of file pixabay.py.

◆ time_range_support

bool searx.engines.pixabay.time_range_support = True

Definition at line 25 of file pixabay.py.