Repository: ytdl-org/youtube-dl

Issue:
Vimeo password auth doesn't work
`$ youtube-dl -p crestone http://vimeo.com/62589042
youtube-dl: error: account username missing`
In this case a username isn't required, just the password.



Discussion:
Thanks for reporting this, we simply haven't considered password-based auth yet. We'll integrate it sometime, but feel free to provide patches to speed that up.

I don't know how to work with this type of web form auth. Wish some coaching, on how to code this, I'd gladly help submit a patch.

On Apr 18, 2013, at 12:37 AM, Philipp Hagemeister notifications@github.com wrote:

> Thanks for reporting this, we simply haven't considered password-based auth yet. We'll integrate it sometime, but feel free to provide patches to speed that up.
> 
> \
> Reply to this email directly or view it on GitHub.


Resolving patch:
diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py
--- a/youtube_dl/InfoExtractors.py
+++ b/youtube_dl/InfoExtractors.py
@@ -1063,6 +1063,25 @@ class VimeoIE(InfoExtractor):
     _VALID_URL = r'(?P<proto>https?://)?(?:(?:www|player)\.)?vimeo(?P<pro>pro)?\.com/(?:(?:(?:groups|album)/[^/]+)|(?:.*?)/)?(?P<direct_link>play_redirect_hls\?clip_id=)?(?:videos?/)?(?P<id>[0-9]+)'
     IE_NAME = u'vimeo'
 
+    def _verify_video_password(self, url, video_id, webpage):
+        password = self._downloader.params.get('password', None)
+        if password is None:
+            raise ExtractorError(u'This video is protected by a password, use the --password option')
+        token = re.search(r'xsrft: \'(.*?)\'', webpage).group(1)
+        data = compat_urllib_parse.urlencode({'password': password,
+                                              'token': token})
+        # I didn't manage to use the password with https
+        if url.startswith('https'):
+            pass_url = url.replace('https','http')
+        else:
+            pass_url = url
+        password_request = compat_urllib_request.Request(pass_url+'/password', data)
+        password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
+        password_request.add_header('Cookie', 'xsrft=%s' % token)
+        pass_web = self._download_webpage(password_request, video_id,
+                                          u'Verifying the password',
+                                          u'Wrong password')
+
     def _real_extract(self, url, new_video=True):
         # Extract ID from URL
         mobj = re.match(self._VALID_URL, url)
@@ -1091,6 +1110,10 @@ def _real_extract(self, url, new_video=True):
         except:
             if re.search('The creator of this video has not given you permission to embed it on this domain.', webpage):
                 raise ExtractorError(u'The author has restricted the access to this video, try with the "--referer" option')
+
+            if re.search('If so please provide the correct password.', webpage):
+                self._verify_video_password(url, video_id, webpage)
+                return self._real_extract(url)
             else:
                 raise ExtractorError(u'Unable to extract info section')
 
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -423,7 +423,7 @@ def _real_main(argv=None):
     if opts.usenetrc and (opts.username is not None or opts.password is not None):
         parser.error(u'using .netrc conflicts with giving username/password')
     if opts.password is not None and opts.username is None:
-        parser.error(u'account username missing')
+        print(u'WARNING: account username missing')
     if opts.outtmpl is not None and (opts.usetitle or opts.autonumber or opts.useid):
         parser.error(u'using output template conflicts with using title, video ID or auto number')
     if opts.usetitle and opts.useid:


Test patch: