1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-12-26 00:07:55 +01:00

[intldropout] moved login to VHXEmbedIE

This commit is contained in:
Thomas Tsiakalakis 2019-05-08 16:51:08 +02:00
parent 80af001a69
commit e53f2ee17f
2 changed files with 26 additions and 27 deletions

View File

@ -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)

View File

@ -1128,6 +1128,30 @@ class VHXEmbedIE(InfoExtractor):
IE_NAME = 'vhx:embed'
_VALID_URL = r'https?://embed\.vhx\.tv/videos/(?P<id>\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={