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

Functions

 request (query, params)
 response (resp)

Variables

dict about
list categories = ['videos', 'web']
bool paging = True
bool safesearch = True
bool time_range_support = True
str base_url = 'https://www.bing.com/videos/asyncv2'

Detailed Description

Bing-Videos: description see :py:obj:`searx.engines.bing`.

Function Documentation

◆ request()

searx.engines.bing_videos.request ( query,
params )
Assemble a Bing-Video request.

Definition at line 35 of file bing_videos.py.

35def request(query, params):
36 """Assemble a Bing-Video request."""
37
38 engine_region = traits.get_region(params['searxng_locale'], traits.all_locale) # type: ignore
39 engine_language = traits.get_language(params['searxng_locale'], 'en') # type: ignore
40 set_bing_cookies(params, engine_language, engine_region)
41
42 # build URL query
43 #
44 # example: https://www.bing.com/videos/asyncv2?q=foo&async=content&first=1&count=35
45
46 query_params = {
47 'q': query,
48 'async': 'content',
49 # to simplify the page count lets use the default of 35 images per page
50 'first': (int(params.get('pageno', 1)) - 1) * 35 + 1,
51 'count': 35,
52 }
53
54 # time range
55 #
56 # example: one week (10080 minutes) '&qft= filterui:videoage-lt10080' '&form=VRFLTR'
57
58 if params['time_range']:
59 query_params['form'] = 'VRFLTR'
60 query_params['qft'] = ' filterui:videoage-lt%s' % time_map[params['time_range']]
61
62 params['url'] = base_url + '?' + urlencode(query_params)
63
64 return params
65
66

◆ response()

searx.engines.bing_videos.response ( resp)
Get response from Bing-Video

Definition at line 67 of file bing_videos.py.

67def response(resp):
68 """Get response from Bing-Video"""
69 results = []
70
71 dom = html.fromstring(resp.text)
72
73 for result in dom.xpath('//div[@class="dg_u"]//div[contains(@id, "mc_vtvc_video")]'):
74 metadata = json.loads(result.xpath('.//div[@class="vrhdata"]/@vrhm')[0])
75 info = ' - '.join(result.xpath('.//div[@class="mc_vtvc_meta_block"]//span/text()')).strip()
76 content = '{0} - {1}'.format(metadata['du'], info)
77 thumbnail = result.xpath('.//div[contains(@class, "mc_vtvc_th")]//img/@src')[0]
78
79 results.append(
80 {
81 'url': metadata['murl'],
82 'thumbnail': thumbnail,
83 'title': metadata.get('vt', ''),
84 'content': content,
85 'template': 'videos.html',
86 }
87 )
88
89 return results

Variable Documentation

◆ about

dict searx.engines.bing_videos.about
Initial value:
1= {
2 "website": 'https://www.bing.com/videos',
3 "wikidata_id": 'Q4914152',
4 "official_api_documentation": 'https://www.microsoft.com/en-us/bing/apis/bing-video-search-api',
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": 'HTML',
8}

Definition at line 16 of file bing_videos.py.

◆ base_url

str searx.engines.bing_videos.base_url = 'https://www.bing.com/videos/asyncv2'

Definition at line 31 of file bing_videos.py.

◆ categories

list searx.engines.bing_videos.categories = ['videos', 'web']

Definition at line 26 of file bing_videos.py.

◆ paging

bool searx.engines.bing_videos.paging = True

Definition at line 27 of file bing_videos.py.

◆ safesearch

bool searx.engines.bing_videos.safesearch = True

Definition at line 28 of file bing_videos.py.

◆ time_range_support

bool searx.engines.bing_videos.time_range_support = True

Definition at line 29 of file bing_videos.py.