aboutsummaryrefslogtreecommitdiffstats
path: root/hypervideo_dl/extractor/linuxacademy.py
diff options
context:
space:
mode:
authorJesus <heckyel@riseup.net>2023-09-04 01:59:36 +0800
committerJesus <heckyel@riseup.net>2023-09-04 01:59:36 +0800
commitb3013540b41d1eb77c4803c5fca46f8d75b40fc1 (patch)
tree97735cb0c49f3a2b0f276e1cd90817833d590d69 /hypervideo_dl/extractor/linuxacademy.py
parenteaeeef9c1d1bedb76fea953c332ef84d53bffe2c (diff)
downloadhypervideo-b3013540b41d1eb77c4803c5fca46f8d75b40fc1.tar.lz
hypervideo-b3013540b41d1eb77c4803c5fca46f8d75b40fc1.tar.xz
hypervideo-b3013540b41d1eb77c4803c5fca46f8d75b40fc1.zip
update from upstream
Diffstat (limited to 'hypervideo_dl/extractor/linuxacademy.py')
-rw-r--r--hypervideo_dl/extractor/linuxacademy.py20
1 files changed, 8 insertions, 12 deletions
diff --git a/hypervideo_dl/extractor/linuxacademy.py b/hypervideo_dl/extractor/linuxacademy.py
index a570248..0b16442 100644
--- a/hypervideo_dl/extractor/linuxacademy.py
+++ b/hypervideo_dl/extractor/linuxacademy.py
@@ -2,11 +2,8 @@ import json
import random
from .common import InfoExtractor
-from ..compat import (
- compat_b64decode,
- compat_HTTPError,
- compat_str,
-)
+from ..compat import compat_b64decode, compat_str
+from ..networking.exceptions import HTTPError
from ..utils import (
clean_html,
ExtractorError,
@@ -75,9 +72,8 @@ class LinuxAcademyIE(InfoExtractor):
def _perform_login(self, username, password):
def random_string():
- return ''.join([
- random.choice('0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._~')
- for _ in range(32)])
+ return ''.join(random.choices(
+ '0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._~', k=32))
webpage, urlh = self._download_webpage_handle(
self._AUTHORIZE_URL, None, 'Downloading authorize page', query={
@@ -108,7 +104,7 @@ class LinuxAcademyIE(InfoExtractor):
'sso': 'true',
})
- login_state_url = urlh.geturl()
+ login_state_url = urlh.url
try:
login_page = self._download_webpage(
@@ -120,8 +116,8 @@ class LinuxAcademyIE(InfoExtractor):
'Referer': login_state_url,
})
except ExtractorError as e:
- if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
- error = self._parse_json(e.cause.read(), None)
+ if isinstance(e.cause, HTTPError) and e.cause.status == 401:
+ error = self._parse_json(e.cause.response.read(), None)
message = error.get('description') or error['code']
raise ExtractorError(
'%s said: %s' % (self.IE_NAME, message), expected=True)
@@ -138,7 +134,7 @@ class LinuxAcademyIE(InfoExtractor):
})
access_token = self._search_regex(
- r'access_token=([^=&]+)', urlh.geturl(),
+ r'access_token=([^=&]+)', urlh.url,
'access token', default=None)
if not access_token:
access_token = self._parse_json(