[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
parent 028f6437f1
commit 52efa4b312
68 changed files with 253 additions and 569 deletions

View File

@@ -25,13 +25,11 @@ class ZattooPlatformBaseIE(InfoExtractor):
def _host_url(self):
return 'https://%s' % (self._API_HOST if hasattr(self, '_API_HOST') else self._HOST)
def _login(self):
username, password = self._get_login_info()
if not username or not password:
self.raise_login_required(
'A valid %s account is needed to access this media.'
% self._NETRC_MACHINE)
def _real_initialize(self):
if not self._power_guide_hash:
self.raise_login_required('An account is needed to access this media', method='password')
def _perform_login(self, username, password):
try:
data = self._download_json(
'%s/zapi/v2/account/login' % self._host_url(), None, 'Logging in',
@@ -52,7 +50,7 @@ class ZattooPlatformBaseIE(InfoExtractor):
self._power_guide_hash = data['session']['power_guide_hash']
def _real_initialize(self):
def _initialize_pre_login(self):
webpage = self._download_webpage(
self._host_url(), None, 'Downloading app token')
app_token = self._html_search_regex(
@@ -72,8 +70,6 @@ class ZattooPlatformBaseIE(InfoExtractor):
'format': 'json',
}))
self._login()
def _extract_cid(self, video_id, channel_name):
channel_groups = self._download_json(
'%s/zapi/v2/cached/channels/%s' % (self._host_url(),