diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2022-02-19 21:27:20 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2022-02-19 21:59:12 +0100 |
commit | 2921d3cd17987fabf66f7a901fc8afeedb3351ef (patch) | |
tree | 6c383dafb4255576dbdac0f9bee6c44c08d51610 /searx/engines/mixcloud.py | |
parent | 883e9c1ddd1cf2af0dc6e9b82885219150b9e849 (diff) | |
download | searxng-2921d3cd17987fabf66f7a901fc8afeedb3351ef.tar.gz searxng-2921d3cd17987fabf66f7a901fc8afeedb3351ef.zip |
[mod] add artwork to mixcloud & soundcloud engines
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/mixcloud.py')
-rw-r--r-- | searx/engines/mixcloud.py | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/searx/engines/mixcloud.py b/searx/engines/mixcloud.py index af5126304..3f255697e 100644 --- a/searx/engines/mixcloud.py +++ b/searx/engines/mixcloud.py @@ -1,11 +1,11 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" - Mixcloud (Music) +# lint: pylint +"""Mixcloud (Music) + """ -from json import loads -from dateutil import parser from urllib.parse import urlencode +from dateutil import parser # about about = { @@ -26,38 +26,29 @@ url = 'https://api.mixcloud.com/' search_url = url + 'search/?{query}&type=cloudcast&limit=10&offset={offset}' iframe_src = "https://www.mixcloud.com/widget/iframe/?feed={url}" -# do search-request + def request(query, params): offset = (params['pageno'] - 1) * 10 - params['url'] = search_url.format(query=urlencode({'q': query}), offset=offset) - return params -# get response from search-request def response(resp): results = [] + search_res = resp.json() - search_res = loads(resp.text) - - # parse results for result in search_res.get('data', []): - title = result['name'] - url = result['url'] - content = result['user']['name'] + + r_url = result['url'] publishedDate = parser.parse(result['created_time']) + res = { + 'url': r_url, + 'title': result['name'], + 'iframe_src': iframe_src.format(url=r_url), + 'img_src': result['pictures']['medium'], + 'publishedDate': publishedDate, + 'content': result['user']['name'], + } + results.append(res) - # append result - results.append( - { - 'url': url, - 'title': title, - 'iframe_src': iframe_src.format(url=url), - 'publishedDate': publishedDate, - 'content': content, - } - ) - - # return results return results |