@@ -1,16 +1,17 @@
11from urllib import urlencode
2+from lxml import html
23from json import loads
34from cgi import escape
45
56categories = ['videos']
6−localization = 'en'
7+locale = 'en_US'
78
89# see http://www.dailymotion.com/doc/api/obj-video.html
910search_url = 'https://api.dailymotion.com/videos?fields=title,description,duration,url,thumbnail_360_url&sort=relevance&limit=25&page=1&{query}'
1011
1112def request(query, params):
1213 global search_url
13− params['url'] = search_url.format(query=urlencode({'search': query, 'localization': localization }))
14+ params['url'] = search_url.format(query=urlencode({'search': query, 'localization': locale }))
1415 return params
1516
1617
@@ -27,6 +28,11 @@ def response(resp):
2728 else:
2829 content = ''
2930 if res['description']:
30− content += escape(res['description'][:500])
31+ description = text_content_from_html(res['description'])
32+ content += description[:500]
3133 results.append({'url': url, 'title': title, 'content': content})
3234 return results
35+
36+def text_content_from_html(html_string):
37+ desc_html = html.fragment_fromstring(html_string, create_parent=True)
38+ return desc_html.text_content()