summaryrefslogtreecommitdiff
path: root/searx/engines/dailymotion.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/dailymotion.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/dailymotion.py')
-rw-r--r--searx/engines/dailymotion.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/searx/engines/dailymotion.py b/searx/engines/dailymotion.py
index a5bffa866..03b1dbb8b 100644
--- a/searx/engines/dailymotion.py
+++ b/searx/engines/dailymotion.py
@@ -6,12 +6,14 @@
# @using-api yes
# @results JSON
# @stable yes
-# @parse url, title, thumbnail
+# @parse url, title, thumbnail, publishedDate, embedded
#
# @todo set content-parameter with correct data
from urllib import urlencode
from json import loads
+from cgi import escape
+from datetime import datetime
# engine dependent config
categories = ['videos']
@@ -20,7 +22,9 @@ language_support = True
# search-url
# see http://www.dailymotion.com/doc/api/obj-video.html
-search_url = 'https://api.dailymotion.com/videos?fields=title,description,duration,url,thumbnail_360_url&sort=relevance&limit=5&page={pageno}&{query}' # noqa
+search_url = 'https://api.dailymotion.com/videos?fields=created_time,title,description,duration,url,thumbnail_360_url,id&sort=relevance&limit=5&page={pageno}&{query}' # noqa
+embedded_url = '<iframe frameborder="0" width="540" height="304" ' +\
+ 'data-src="//www.dailymotion.com/embed/video/{videoid}" allowfullscreen></iframe>'
# do search-request
@@ -51,14 +55,17 @@ def response(resp):
for res in search_res['list']:
title = res['title']
url = res['url']
- #content = res['description']
- content = ''
+ content = escape(res['description'])
thumbnail = res['thumbnail_360_url']
+ publishedDate = datetime.fromtimestamp(res['created_time'], None)
+ embedded = embedded_url.format(videoid=res['id'])
results.append({'template': 'videos.html',
'url': url,
'title': title,
'content': content,
+ 'publishedDate': publishedDate,
+ 'embedded': embedded,
'thumbnail': thumbnail})
# return results