3 from .common
import InfoExtractor
11 class SCTEBaseIE(InfoExtractor
):
12 _LOGIN_URL
= 'https://www.scte.org/SCTE/Sign_In.aspx'
13 _NETRC_MACHINE
= 'scte'
15 def _perform_login(self
, username
, password
):
16 login_popup
= self
._download
_webpage
(
17 self
._LOGIN
_URL
, None, 'Downloading login popup')
19 def is_logged(webpage
):
20 return any(re
.search(p
, webpage
) for p
in (
21 r
'class=["\']welcome
\b', r'>Sign Out
<'))
24 if is_logged(login_popup):
27 login_form = self._hidden_inputs(login_popup)
30 'ctl01$TemplateBody$WebPartManager1$gwpciNewContactSignInCommon$ciNewContactSignInCommon$signInUserName
': username,
31 'ctl01$TemplateBody$WebPartManager1$gwpciNewContactSignInCommon$ciNewContactSignInCommon$signInPassword
': password,
32 'ctl01$TemplateBody$WebPartManager1$gwpciNewContactSignInCommon$ciNewContactSignInCommon$RememberMe
': 'on
',
35 response = self._download_webpage(
36 self._LOGIN_URL, None, 'Logging
in',
37 data=urlencode_postdata(login_form))
39 if '|pageRedirect|
' not in response and not is_logged(response):
40 error = self._html_search_regex(
41 r'(?s
)<[^
>]+class=["\']AsiError["\'][^
>]*>(.+?
)</',
42 response, 'error message
', default=None)
44 raise ExtractorError(f'Unable to login
: {error}
', expected=True)
45 raise ExtractorError('Unable to log
in')
48 class SCTEIE(SCTEBaseIE):
50 _VALID_URL = r'https?
://learning\
.scte\
.org
/mod
/scorm
/view\
.php?
.*?
\bid
=(?P
<id>\d
+)'
52 'url
': 'https
://learning
.scte
.org
/mod
/scorm
/view
.php?
id=31484',
54 'title
': 'Introduction to DOCSIS Engineering Professional
',
58 'skip
': 'Requires account credentials
',
61 def _real_extract(self, url):
62 video_id = self._match_id(url)
64 webpage = self._download_webpage(url, video_id)
66 title = self._search_regex(r'<h1
>(.+?
)</h1
>', webpage, 'title
')
68 context_id = self._search_regex(r'context
-(\d
+)', webpage, video_id)
69 content_base = f'https
://learning
.scte
.org
/pluginfile
.php
/{context_id}
/mod_scorm
/content
/8/'
70 context = decode_packed_codes(self._download_webpage(
71 f'{content_base}mobile
/data
.js
', video_id))
73 data = self._parse_xml(
75 r'CreateData\
(\s
*"(.+?)"', context, 'data
').replace(r"\'", "'"),
79 for asset in data.findall('.//asset'):
80 asset_url = asset.get('url')
81 if not asset_url or not asset_url.endswith('.mp4'):
83 asset_id = self._search_regex(
84 r'video_([^_]+)_', asset_url, 'asset id', default=None)
90 'url': content_base + asset_url,
93 return self.playlist_result(entries, video_id, title)
96 class SCTECourseIE(SCTEBaseIE):
98 _VALID_URL = r'https?://learning\.scte\.org/(?:mod/sub)?course/view\.php?.*?\bid=(?P<id>\d+)'
100 'url': 'https://learning.scte.org/mod/subcourse/view.php?id=31491',
101 'only_matching': True,
103 'url': 'https://learning.scte.org/course/view.php?id=3639',
104 'only_matching': True,
106 'url': 'https://learning.scte.org/course/view.php?id=3073',
107 'only_matching': True,
110 def _real_extract(self, url):
111 course_id = self._match_id(url)
113 webpage = self._download_webpage(url, course_id)
115 title = self._search_regex(
116 r'<h1>(.+?)</h1>', webpage, 'title', default=None)
119 for mobj in re.finditer(
124 https?
://learning\
.scte\
.org
/mod
/
125 (?P
<kind
>scorm|subcourse
)/view\
.php?
(?
:(?
!\
1).)*?
130 item_url = mobj.group('url')
133 ie = (SCTEIE.ie_key() if mobj.group('kind') == 'scorm'
134 else SCTECourseIE.ie_key())
135 entries.append(self.url_result(item_url, ie=ie))
137 return self.playlist_result(entries, course_id, title)