summaryrefslogtreecommitdiff
path: root/searx/engines/soundcloud.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2022-02-19 21:27:20 +0100
committerMarkus Heiser <markus.heiser@darmarit.de>2022-02-19 21:59:12 +0100
commit2921d3cd17987fabf66f7a901fc8afeedb3351ef (patch)
tree6c383dafb4255576dbdac0f9bee6c44c08d51610 /searx/engines/soundcloud.py
parent883e9c1ddd1cf2af0dc6e9b82885219150b9e849 (diff)
downloadsearxng-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/soundcloud.py')
-rw-r--r--searx/engines/soundcloud.py28
1 files changed, 12 insertions, 16 deletions
diff --git a/searx/engines/soundcloud.py b/searx/engines/soundcloud.py
index e189c5d8e..78947c69c 100644
--- a/searx/engines/soundcloud.py
+++ b/searx/engines/soundcloud.py
@@ -81,27 +81,23 @@ def request(query, params):
# get response from search-request
def response(resp):
results = []
-
search_res = loads(resp.text)
# parse results
for result in search_res.get('collection', []):
+
if result['kind'] in ('track', 'playlist'):
- title = result['title']
- content = result['description'] or ''
- publishedDate = parser.parse(result['last_modified'])
uri = quote_plus(result['uri'])
+ res = {
+ 'url': result['permalink_url'],
+ 'title': result['title'],
+ 'content': result['description'] or '',
+ 'publishedDate': parser.parse(result['last_modified']),
+ 'iframe_src': "https://w.soundcloud.com/player/?url=" + uri,
+ }
+ img_src = result['artwork_url'] or result['user']['avatar_url']
+ if img_src:
+ res['img_src'] = img_src
+ results.append(res)
- # append result
- results.append(
- {
- 'url': result['permalink_url'],
- 'title': title,
- 'publishedDate': publishedDate,
- 'iframe_src': "https://w.soundcloud.com/player/?url=" + uri,
- 'content': content,
- }
- )
-
- # return results
return results