@@ -2,6 +2,8 @@ from urllib import urlencode
22from HTMLParser import HTMLParser
33from lxml import html
44from xpath import extract_text
5+from datetime import datetime
6+from dateutil import parser
57
68base_url = 'http://vimeo.com'
79search_url = base_url + '/search?{query}'
@@ -10,6 +12,7 @@ content_xpath = None
1012title_xpath = None
1113results_xpath = ''
1214content_tpl = '<a href="{0}"> <img src="{2}"/> </a>'
15+publishedDate_xpath = './/p[@class="meta"]//attribute::datetime'
1316
1417# the cookie set by vimeo contains all the following values,
1518# but only __utma seems to be requiered
@@ -40,9 +43,12 @@ def response(resp):
4043 url = base_url + result.xpath(url_xpath)[0]
4144 title = p.unescape(extract_text(result.xpath(title_xpath)))
4245 thumbnail = extract_text(result.xpath(content_xpath)[0])
46+ publishedDate = parser.parse(extract_text(result.xpath(publishedDate_xpath)[0]))
47+
4348 results.append({'url': url,
4449 'title': title,
4550 'content': content_tpl.format(url, title, thumbnail),
4651 'template': 'videos.html',
52+ 'publishedDate': publishedDate,
4753 'thumbnail': thumbnail})
4854 return results