.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
vimeo.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""
3 Wikipedia (Web
4"""
5
6from urllib.parse import urlencode
7from json import loads
8from dateutil import parser
9
10from searx.utils import extr
11
12# about
13about = {
14 "website": 'https://vimeo.com/',
15 "wikidata_id": 'Q156376',
16 "official_api_documentation": 'http://developer.vimeo.com/api',
17 "use_official_api": False,
18 "require_api_key": False,
19 "results": 'HTML',
20}
21
22# engine dependent config
23categories = ['videos']
24paging = True
25
26# search-url
27base_url = 'https://vimeo.com/'
28search_url = base_url + 'search/page:{pageno}?{query}'
29
30
31# do search-request
32def request(query, params):
33 params['url'] = search_url.format(pageno=params['pageno'], query=urlencode({'q': query}))
34
35 return params
36
37
38# get response from search-request
39def response(resp):
40 results = []
41
42 data = loads(extr(resp.text, 'var data = ', ';\n'))
43
44 # parse results
45 for result in data['filtered']['data']:
46 result = result[result['type']]
47 videoid = result['uri'].split('/')[-1]
48 url = base_url + videoid
49 title = result['name']
50 thumbnail = result['pictures']['sizes'][-1]['link']
51 publishedDate = parser.parse(result['created_time'])
52
53 # append result
54 results.append(
55 {
56 'url': url,
57 'title': title,
58 'content': '',
59 'template': 'videos.html',
60 'publishedDate': publishedDate,
61 'iframe_src': "https://player.vimeo.com/video/" + videoid,
62 'thumbnail': thumbnail,
63 }
64 )
65
66 # return results
67 return results
request(query, params)
Definition vimeo.py:32