summaryrefslogtreecommitdiff
path: root/searx/engines/youtube.py
diff options
context:
space:
mode:
authorThomas Pointhuber <thomas.pointhuber@gmx.at>2015-01-09 21:25:13 +0100
committerThomas Pointhuber <thomas.pointhuber@gmx.at>2015-01-09 21:30:09 +0100
commit400b54191c590663f0cfe91045f70a5d9223aa19 (patch)
tree08c71466ac8fbaf69872f114847baec762f5bd81 /searx/engines/youtube.py
parentaf8dac93a8acff5042b7b399c38e348f0bdc32ad (diff)
parentc8be128e97479ea6c871c4b6fbf014fa8136e708 (diff)
Merge branch 'master' of https://github.com/asciimoo/searx into code_results
Conflicts: searx/engines/searchcode_code.py searx/engines/searchcode_doc.py searx/static/oscar/js/searx.min.js searx/templates/oscar/result_templates/default.html searx/templates/oscar/result_templates/images.html searx/templates/oscar/result_templates/map.html searx/templates/oscar/result_templates/torrent.html searx/templates/oscar/result_templates/videos.html
Diffstat (limited to 'searx/engines/youtube.py')
-rw-r--r--searx/engines/youtube.py13
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