[vimeo] Add support for passwords for player. URLs
authorPhilipp Hagemeister <phihag@phihag.de>
Tue, 7 Jan 2014 08:51:57 +0000 (09:51 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Tue, 7 Jan 2014 08:52:00 +0000 (09:52 +0100)
Fixes #2053

youtube_dl/extractor/vimeo.py

index 81c495d1e713d5190020d3966f36ed2c16e055d5..540ca4fcc908b209e7972e10908f243e943163c9 100644 (file)
@@ -124,6 +124,19 @@ class VimeoIE(InfoExtractor):
                                'Verifying the password',
                                'Wrong password')
 
+    def _verify_player_video_password(self, url, video_id):
+        password = self._downloader.params.get('videopassword', None)
+        if password is None:
+            raise ExtractorError('This video is protected by a password, use the --video-password option')
+        data = compat_urllib_parse.urlencode({'password': password})
+        pass_url = url + '/check-password'
+        password_request = compat_urllib_request.Request(pass_url, data)
+        password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
+        return self._download_json(
+            password_request, video_id,
+            'Verifying the password',
+            'Wrong password')
+
     def _real_initialize(self):
         self._login()
 
@@ -184,8 +197,7 @@ class VimeoIE(InfoExtractor):
                                      cause=e)
         else:
             if config.get('view') == 4:
-                self._verify_video_password(url, video_id, webpage)
-                return self._real_extract(url)
+                config = self._verify_player_video_password(url, video_id)
 
         # Extract title
         video_title = config["video"]["title"]