diff --git a/youtube_dl/extractor/intldropout.py b/youtube_dl/extractor/intldropout.py index 493dfe525..1cdc7e125 100644 --- a/youtube_dl/extractor/intldropout.py +++ b/youtube_dl/extractor/intldropout.py @@ -3,10 +3,7 @@ from __future__ import unicode_literals from .vimeo import VHXEmbedIE -from ..utils import ( - ExtractorError, - urlencode_postdata, -) +from ..utils import ExtractorError import re @@ -54,29 +51,7 @@ class IntlDropoutIE(VHXEmbedIE): email, password = self._get_login_info() if (email is None or password is None) and self._downloader.params.get('cookiefile') is None: raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True) - - login_page = self._download_webpage( - self._LOGIN_URL, None, - note='Downloading login page', - errnote='unable to fetch login page' - ) - - """check if user is already logged in via cookies""" - if "You are now signed in." in login_page: - return - - login_form = self._hidden_inputs(login_page) - - login_form.update({ - 'passwordless': 0, - 'email': email, - 'password': password - }) - - self._download_webpage(self._LOGIN_URL, None, 'Logging in', 'Login failed', - expected_status=302, - data=urlencode_postdata(login_form), - headers={'Content-Type': 'application/x-www-form-urlencoded'}) + self._vhx_login(email, password, self._LOGIN_URL) def _real_extract(self, url): webpage = self._download_webpage(url, None) diff --git a/youtube_dl/extractor/vimeo.py b/youtube_dl/extractor/vimeo.py index a41178bab..effa879bc 100644 --- a/youtube_dl/extractor/vimeo.py +++ b/youtube_dl/extractor/vimeo.py @@ -1128,6 +1128,30 @@ class VHXEmbedIE(InfoExtractor): IE_NAME = 'vhx:embed' _VALID_URL = r'https?://embed\.vhx\.tv/videos/(?P\d+)' + def _vhx_login(self, email, password, login_url): + login_page = self._download_webpage( + login_url, None, + note='Downloading login page', + errnote='unable to fetch login page' + ) + + """check if user is already logged in via cookies""" + if "You are now signed in." in login_page: + return + + login_form = self._hidden_inputs(login_page) + + login_form.update({ + 'passwordless': 0, + 'email': email, + 'password': password + }) + + self._download_webpage(login_url, None, 'Logging in', 'Login failed', + expected_status=302, + data=urlencode_postdata(login_form), + headers={'Content-Type': 'application/x-www-form-urlencoded'}) + def _call_api(self, video_id, access_token, path='', query=None): return self._download_json( 'https://api.vhx.tv/videos/' + video_id + path, video_id, headers={