1
0
Fork 0

[extractor] Add _perform_login function (#2943)

* Adds new functions `_initialize_pre_login` and `_perform_login` as part of the extractor API
* Adds `ie.supports_login` to the public API
This commit is contained in:
pukkandan 2022-03-19 02:23:33 +05:30 committed by GitHub
commit 52efa4b312
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
68 changed files with 254 additions and 570 deletions

View file

@ -65,11 +65,9 @@ class IPrimaIE(InfoExtractor):
'only_matching': True,
}]
def _login(self):
username, password = self._get_login_info()
if username is None or password is None:
self.raise_login_required('Login is required to access any iPrima content', method='password')
def _perform_login(self, username, password):
if self.access_token:
return
login_page = self._download_webpage(
self._LOGIN_URL, None, note='Downloading login page',
@ -105,16 +103,16 @@ class IPrimaIE(InfoExtractor):
if self.access_token is None:
raise ExtractorError('Getting token failed', expected=True)
def _real_initialize(self):
if not self.access_token:
self.raise_login_required('Login is required to access any iPrima content', method='password')
def _raise_access_error(self, error_code):
if error_code == 'PLAY_GEOIP_DENIED':
self.raise_geo_restricted(countries=['CZ'], metadata_available=True)
elif error_code is not None:
self.raise_no_formats('Access to stream infos forbidden', expected=True)
def _real_initialize(self):
if not self.access_token:
self._login()
def _real_extract(self, url):
video_id = self._match_id(url)