From e1d3e43a4d53b297c5166c996b2a5feae078a29c Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Thu, 15 Mar 2012 23:48:54 +0100 Subject: [PATCH] Fix getting dailymotion thumbnails It is now in "data-src" instead of "src", because they use JavaScript lazy loading. Also ask for the bigger thumbnail, and remove useless anti-caching. --- modules/dailymotion/pages.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/dailymotion/pages.py b/modules/dailymotion/pages.py index 8a720ea7..d919bb96 100644 --- a/modules/dailymotion/pages.py +++ b/modules/dailymotion/pages.py @@ -67,7 +67,11 @@ class IndexPage(BasePage): else: raise BrokenPageError('Unable to parse duration %r' % self.parser.select(div, 'div.duration', 1).text) video.duration = datetime.timedelta(hours=int(hours), minutes=int(minutes), seconds=int(seconds)) - url = self.parser.select(div, 'img.dmco_image', 1).attrib['src'] + url = self.parser.select(div, 'img.dmco_image', 1).attrib['data-src'] + # remove the useless anti-caching + url = re.sub('\?\d+', '', url) + # use the bigger thumbnail + url = url.replace('jpeg_preview_medium.jpg', 'jpeg_preview_large.jpg') video.thumbnail = Thumbnail(url) rating_div = self.parser.select(div, 'div.small_stars', 1)