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/sonyliv.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/sonyliv.py')
-rw-r--r-- | yt_dlp/extractor/sonyliv.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/yt_dlp/extractor/sonyliv.py b/yt_dlp/extractor/sonyliv.py index a5026b2e0..5b6849fc9 100644 --- a/yt_dlp/extractor/sonyliv.py +++ b/yt_dlp/extractor/sonyliv.py @@ -75,9 +75,12 @@ class SonyLIVIE(InfoExtractor): t[i] = '{:x}'.format(3 & n | 8) return ''.join(t) + '-' + str(int(time.time() * 1000)) - def _login(self, username, password): + def _perform_login(self, username, password): + self._HEADERS['device_id'] = self._get_device_id() + self._HEADERS['content-type'] = 'application/json' + if username.lower() == 'token' and len(password) > 1198: - return password + self._HEADERS['authorization'] = password elif len(username) != 10 or not username.isdigit(): raise ExtractorError(f'Invalid username/password; {self._LOGIN_HINT}') @@ -99,7 +102,7 @@ class SonyLIVIE(InfoExtractor): None, note='Verifying OTP', data=data.encode(), headers=self._HEADERS) if otp_verify_json['resultCode'] == 'KO': raise ExtractorError(otp_request_json['message'], expected=True) - return otp_verify_json['resultObj']['accessToken'] + self._HEADERS['authorization'] = otp_verify_json['resultObj']['accessToken'] def _call_api(self, version, path, video_id): try: @@ -118,13 +121,8 @@ class SonyLIVIE(InfoExtractor): raise ExtractorError(message) raise - def _real_initialize(self): + def _initialize_pre_login(self): self._HEADERS['security_token'] = self._call_api('1.4', 'ALL/GETTOKEN', None) - username, password = self._get_login_info() - if username: - self._HEADERS['device_id'] = self._get_device_id() - self._HEADERS['content-type'] = 'application/json' - self._HEADERS['authorization'] = self._login(username, password) def _real_extract(self, url): video_id = self._match_id(url) |