diff options
author | Cqoicebordel <Cqoicebordel@users.noreply.github.com> | 2015-01-05 02:04:23 +0100 |
---|---|---|
committer | Cqoicebordel <Cqoicebordel@users.noreply.github.com> | 2015-01-05 02:04:23 +0100 |
commit | 4a195e0b28fdd940e046c442032c816095416fec (patch) | |
tree | 88a4d4b151bbd9771cb1a58cf37f7691737af9e4 /searx/engines/youtube.py | |
parent | 7b531c6fcefe1c0c5cc19967454cdddb6e1c8fbd (diff) | |
download | searxng-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/youtube.py')
-rw-r--r-- | searx/engines/youtube.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/searx/engines/youtube.py b/searx/engines/youtube.py index 973e799f8..59f07c574 100644 --- a/searx/engines/youtube.py +++ b/searx/engines/youtube.py @@ -6,7 +6,7 @@ # @using-api yes # @results JSON # @stable yes -# @parse url, title, content, publishedDate, thumbnail +# @parse url, title, content, publishedDate, thumbnail, embedded from json import loads from urllib import urlencode @@ -19,7 +19,11 @@ language_support = True # search-url base_url = 'https://gdata.youtube.com/feeds/api/videos' -search_url = base_url + '?alt=json&{query}&start-index={index}&max-results=5' # noqa +search_url = base_url + '?alt=json&{query}&start-index={index}&max-results=5' + +embedded_url = '<iframe width="540" height="304" ' +\ + 'data-src="//www.youtube-nocookie.com/embed/{videoid}" ' +\ + 'frameborder="0" allowfullscreen></iframe>' # do search-request @@ -60,6 +64,8 @@ def response(resp): if url.endswith('&'): url = url[:-1] + videoid = url[32:] + title = result['title']['$t'] content = '' thumbnail = '' @@ -72,12 +78,15 @@ def response(resp): content = result['content']['$t'] + embedded = embedded_url.format(videoid=videoid) + # append result results.append({'url': url, 'title': title, 'content': content, 'template': 'videos.html', 'publishedDate': publishedDate, + 'embedded': embedded, 'thumbnail': thumbnail}) # return results |