From b57dd8c669a28b20ecabfb3c58cf16c05f1a61ba Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Fri, 20 Jun 2014 10:13:34 +0200 Subject: [PATCH] fix compatibility with website changes --- modules/vimeo/pages.py | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/modules/vimeo/pages.py b/modules/vimeo/pages.py index 1b1940ec..5f76f346 100644 --- a/modules/vimeo/pages.py +++ b/modules/vimeo/pages.py @@ -80,7 +80,7 @@ class VideoPage(BasePage): # Else fall back to the API if data is None: # for the rest, use the JSON config descriptor - json_data = self.browser.openurl('http://%s/config/%s?type=%s&referrer=%s' % ("player.vimeo.com", int(v.id), "html5_desktop_local", "")) + json_data = self.browser.openurl('http://%s/video/%s/config?type=%s&referrer=%s' % ("player.vimeo.com", int(v.id), "html5_desktop_local", "")) data = json.load(json_data) if data is None: @@ -98,30 +98,17 @@ class VideoPage(BasePage): # use highest quality possible quality = 'sd' codec = None - if 'vp6' in data['video']['files']: + if 'vp6' in data['request']['files']: codec = 'vp6' - if 'vp8' in data['video']['files']: + if 'vp8' in data['request']['files']: codec = 'vp8' - if 'h264' in data['video']['files']: + if 'h264' in data['request']['files']: codec = 'h264' if not codec: raise BrokenPageError('Unable to detect available codec for id: %r' % int(v.id)) - if 'hd' in data['video']['files'][codec]: + if 'hd' in data['request']['files'][codec]: quality = 'hd' - v.url = unicode("http://player.vimeo.com/play_redirect?quality=%s&codecs=%s&clip_id=%d&time=%s&sig=%s&type=html5_desktop_local" % (quality, codec, int(v.id), data['request']['timestamp'], data['request']['signature'])) - - # attempt to determine the redirected URL to pass it instead - # since the target server doesn't check for User-Agent, unlike - # for the source one. - # HACK: we use mechanize directly here for now... FIXME - #print "asking for redirect on '%s'" % (v.url) - self.browser.set_handle_redirect(False) - try: - self.browser.open_novisit(v.url) - except HTTPError as e: - if e.getcode() == 302 and hasattr(e, 'hdrs'): - #print e.hdrs['Location'] - v.url = unicode(e.hdrs['Location']) - self.browser.set_handle_redirect(True) + v.url = data['request']['files'][codec][quality]['url'] + return v