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

Functions

 request (query, params)
 
 response (resp)
 

Variables

logging logger .Logger
 
EngineTraits traits
 
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 44 of file bing_videos.py.

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

◆ response()

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

Definition at line 76 of file bing_videos.py.

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

References searx.format.

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 25 of file bing_videos.py.

◆ base_url

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

Definition at line 40 of file bing_videos.py.

◆ categories

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

Definition at line 35 of file bing_videos.py.

◆ logger

logging searx.engines.bing_videos.logger .Logger

Definition at line 20 of file bing_videos.py.

◆ paging

bool searx.engines.bing_videos.paging = True

Definition at line 36 of file bing_videos.py.

◆ safesearch

bool searx.engines.bing_videos.safesearch = True

Definition at line 37 of file bing_videos.py.

◆ time_range_support

bool searx.engines.bing_videos.time_range_support = True

Definition at line 38 of file bing_videos.py.

◆ traits

EngineTraits searx.engines.bing_videos.traits

Definition at line 22 of file bing_videos.py.