diff options
author | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2014-09-02 18:12:30 +0200 |
---|---|---|
committer | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2014-09-02 18:12:30 +0200 |
commit | 64a68a7296d356fe28e31a704c3e0d3051220cec (patch) | |
tree | c1e8e75301ce6b18b2aa0e7288a3d61d912f77f5 /searx | |
parent | dae88d862b8de2a7cddf461045ef381b07819fe5 (diff) | |
download | searxng-64a68a7296d356fe28e31a704c3e0d3051220cec.tar.gz searxng-64a68a7296d356fe28e31a704c3e0d3051220cec.zip |
update soundcloud and add comments
Diffstat (limited to 'searx')
-rw-r--r-- | searx/engines/soundcloud.py | 33 | ||||
-rw-r--r-- | searx/settings.yml | 1 |
2 files changed, 29 insertions, 5 deletions
diff --git a/searx/engines/soundcloud.py b/searx/engines/soundcloud.py index 07cdbc273..aebea239f 100644 --- a/searx/engines/soundcloud.py +++ b/searx/engines/soundcloud.py @@ -1,30 +1,55 @@ +## Soundcloud (Music) +# +# @website https://soundcloud.com +# @provide-api yes (https://developers.soundcloud.com/) +# +# @using-api yes +# @results JSON +# @stable yes +# @parse url, title, content + from json import loads from urllib import urlencode +# engine dependent config categories = ['music'] +paging = True +# api-key guest_client_id = 'b45b1aa10f1ac2941910a7f0d10f8e28' -url = 'https://api.soundcloud.com/' -search_url = url + 'search?{query}&facet=model&limit=20&offset={offset}&linked_partitioning=1&client_id='+guest_client_id # noqa -paging = True +# search-url +url = 'https://api.soundcloud.com/' +search_url = url + 'search?{query}&facet=model&limit=20&offset={offset}&linked_partitioning=1&client_id={client_id}' +# do search-request def request(query, params): offset = (params['pageno'] - 1) * 20 + params['url'] = search_url.format(query=urlencode({'q': query}), - offset=offset) + offset=offset, + client_id=guest_client_id) + return 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'] + + # append result results.append({'url': result['permalink_url'], 'title': title, 'content': content}) + + # return results return results diff --git a/searx/settings.yml b/searx/settings.yml index 4a976d36e..00ea2c339 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -86,7 +86,6 @@ engines: - name : soundcloud engine : soundcloud - categories : music shortcut : sc - name : stackoverflow |