diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2015-01-09 04:15:57 +0100 |
|---|---|---|
| committer | Adam Tauber <asciimoo@gmail.com> | 2015-01-09 04:15:57 +0100 |
| commit | d6b1ff08ad2ad3af8ef50c3611a18c633a78249e (patch) | |
| tree | f139bab9b9262327390d3d0da4c6c1efd073f20e /searx/engines/youtube.py | |
| parent | 299a80a1eb2eecb80f5c50da261a9eab1900b572 (diff) | |
| parent | e4681da20f4dc2024609454771aa005bc05ba3f3 (diff) | |
Merge branch 'master' of github.com:asciimoo/searx
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 |