.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
mixcloud.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""Mixcloud (Music)
3
4"""
5
6from urllib.parse import urlencode
7from dateutil import parser
8
9# about
10about = {
11 "website": 'https://www.mixcloud.com/',
12 "wikidata_id": 'Q6883832',
13 "official_api_documentation": 'http://www.mixcloud.com/developers/',
14 "use_official_api": True,
15 "require_api_key": False,
16 "results": 'JSON',
17}
18
19# engine dependent config
20categories = ['music']
21paging = True
22
23# search-url
24url = 'https://api.mixcloud.com/'
25search_url = url + 'search/?{query}&type=cloudcast&limit=10&offset={offset}'
26iframe_src = "https://www.mixcloud.com/widget/iframe/?feed={url}"
27
28
29def request(query, params):
30 offset = (params['pageno'] - 1) * 10
31 params['url'] = search_url.format(query=urlencode({'q': query}), offset=offset)
32 return params
33
34
35def response(resp):
36 results = []
37 search_res = resp.json()
38
39 for result in search_res.get('data', []):
40
41 r_url = result['url']
42 publishedDate = parser.parse(result['created_time'])
43 res = {
44 'url': r_url,
45 'title': result['name'],
46 'iframe_src': iframe_src.format(url=r_url),
47 'thumbnail': result['pictures']['medium'],
48 'publishedDate': publishedDate,
49 'content': result['user']['name'],
50 }
51 results.append(res)
52
53 return results
request(query, params)
Definition mixcloud.py:29