diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-03-19 02:23:33 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-18 13:53:33 -0700 |
commit | 52efa4b31200119adaa8acf33e50b84fcb6948f0 (patch) | |
tree | f1963a4ade1111db9db8edea8fff0a7c58923cf9 /yt_dlp/extractor/imggaming.py | |
parent | 028f6437f1cb45bb9b3b286cba173b0588337feb (diff) | |
download | hypervideo-pre-52efa4b31200119adaa8acf33e50b84fcb6948f0.tar.lz hypervideo-pre-52efa4b31200119adaa8acf33e50b84fcb6948f0.tar.xz hypervideo-pre-52efa4b31200119adaa8acf33e50b84fcb6948f0.zip |
[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
Diffstat (limited to 'yt_dlp/extractor/imggaming.py')
-rw-r--r-- | yt_dlp/extractor/imggaming.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/yt_dlp/extractor/imggaming.py b/yt_dlp/extractor/imggaming.py index 230dc86d3..ce7b21ab2 100644 --- a/yt_dlp/extractor/imggaming.py +++ b/yt_dlp/extractor/imggaming.py @@ -21,25 +21,26 @@ class ImgGamingBaseIE(InfoExtractor): _REALM = None _VALID_URL_TEMPL = r'https?://(?P<domain>%s)/(?P<type>live|playlist|video)/(?P<id>\d+)(?:\?.*?\bplaylistId=(?P<playlist_id>\d+))?' - def _real_initialize(self): + def _initialize_pre_login(self): self._HEADERS = { 'Realm': 'dce.' + self._REALM, 'x-api-key': self._API_KEY, } - email, password = self._get_login_info() - if email is None: - self.raise_login_required() - + def _perform_login(self, username, password): p_headers = self._HEADERS.copy() p_headers['Content-Type'] = 'application/json' self._HEADERS['Authorization'] = 'Bearer ' + self._download_json( self._API_BASE + 'login', None, 'Logging in', data=json.dumps({ - 'id': email, + 'id': username, 'secret': password, }).encode(), headers=p_headers)['authorisationToken'] + def _real_initialize(self): + if not self._HEADERS.get('Authorization'): + self.raise_login_required(method='password') + def _call_api(self, path, media_id): return self._download_json( self._API_BASE + path + media_id, media_id, headers=self._HEADERS) |