summaryrefslogtreecommitdiff
path: root/searx/engines/soundcloud.py
diff options
context:
space:
mode:
authorCqoicebordel <Cqoicebordel@users.noreply.github.com>2015-01-05 02:04:23 +0100
committerCqoicebordel <Cqoicebordel@users.noreply.github.com>2015-01-05 02:04:23 +0100
commit4a195e0b28fdd940e046c442032c816095416fec (patch)
tree88a4d4b151bbd9771cb1a58cf37f7691737af9e4 /searx/engines/soundcloud.py
parent7b531c6fcefe1c0c5cc19967454cdddb6e1c8fbd (diff)
downloadsearxng-4a195e0b28fdd940e046c442032c816095416fec.tar.gz
searxng-4a195e0b28fdd940e046c442032c816095416fec.zip
Integrated media in results + Deezer Engine
New "embedded" item for the results, allow to give an iframe to display the media directly in the results. Note that the attributes src of the iframes are not set, but instead data-src is set, allowing to only load the iframe when clicked. Deezer engine based on public API (no key).
Diffstat (limited to 'searx/engines/soundcloud.py')
-rw-r--r--searx/engines/soundcloud.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/searx/engines/soundcloud.py b/searx/engines/soundcloud.py
index 164a569a3..44374af6f 100644
--- a/searx/engines/soundcloud.py
+++ b/searx/engines/soundcloud.py
@@ -6,10 +6,11 @@
# @using-api yes
# @results JSON
# @stable yes
-# @parse url, title, content
+# @parse url, title, content, publishedDate, embedded
from json import loads
-from urllib import urlencode
+from urllib import urlencode, quote_plus
+from dateutil import parser
# engine dependent config
categories = ['music']
@@ -27,6 +28,10 @@ search_url = url + 'search?{query}'\
'&linked_partitioning=1'\
'&client_id={client_id}' # noqa
+embedded_url = '<iframe width="100%" height="166" ' +\
+ 'scrolling="no" frameborder="no" ' +\
+ 'data-src="https://w.soundcloud.com/player/?url={uri}"></iframe>'
+
# do search-request
def request(query, params):
@@ -50,10 +55,15 @@ def response(resp):
if result['kind'] in ('track', 'playlist'):
title = result['title']
content = result['description']
+ publishedDate = parser.parse(result['last_modified'])
+ uri = quote_plus(result['uri'])
+ embedded = embedded_url.format(uri=uri)
# append result
results.append({'url': result['permalink_url'],
'title': title,
+ 'publishedDate': publishedDate,
+ 'embedded': embedded,
'content': content})
# return results