1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
13 class SCTEBaseIE(InfoExtractor
):
14 _LOGIN_URL
= 'https://www.scte.org/SCTE/Sign_In.aspx'
15 _NETRC_MACHINE
= 'scte'
17 def _real_initialize(self
):
21 username
, password
= self
._get
_login
_info
()
25 login_popup
= self
._download
_webpage
(
26 self
._LOGIN
_URL
, None, 'Downloading login popup')
28 def is_logged(webpage
):
29 return any(re
.search(p
, webpage
) for p
in (
30 r
'class=["\']welcome
\b', r'>Sign Out
<'))
33 if is_logged(login_popup):
36 login_form = self._hidden_inputs(login_popup)
39 'ctl01$TemplateBody$WebPartManager1$gwpciNewContactSignInCommon$ciNewContactSignInCommon$signInUserName
': username,
40 'ctl01$TemplateBody$WebPartManager1$gwpciNewContactSignInCommon$ciNewContactSignInCommon$signInPassword
': password,
41 'ctl01$TemplateBody$WebPartManager1$gwpciNewContactSignInCommon$ciNewContactSignInCommon$RememberMe
': 'on
',
44 response = self._download_webpage(
45 self._LOGIN_URL, None, 'Logging
in',
46 data=urlencode_postdata(login_form))
48 if '|pageRedirect|
' not in response and not is_logged(response):
49 error = self._html_search_regex(
50 r'(?s
)<[^
>]+class=["\']AsiError["\'][^
>]*>(.+?
)</',
51 response, 'error message
', default=None)
53 raise ExtractorError('Unable to login
: %s' % error, expected=True)
54 raise ExtractorError('Unable to log
in')
57 class SCTEIE(SCTEBaseIE):
58 _VALID_URL = r'https?
://learning\
.scte\
.org
/mod
/scorm
/view\
.php?
.*?
\bid
=(?P
<id>\d
+)'
60 'url
': 'https
://learning
.scte
.org
/mod
/scorm
/view
.php?
id=31484',
62 'title
': 'Introduction to DOCSIS Engineering Professional
',
66 'skip
': 'Requires account credentials
',
69 def _real_extract(self, url):
70 video_id = self._match_id(url)
72 webpage = self._download_webpage(url, video_id)
74 title = self._search_regex(r'<h1
>(.+?
)</h1
>', webpage, 'title
')
76 context_id = self._search_regex(r'context
-(\d
+)', webpage, video_id)
77 content_base = 'https
://learning
.scte
.org
/pluginfile
.php
/%s/mod_scorm
/content
/8/' % context_id
78 context = decode_packed_codes(self._download_webpage(
79 '%smobile
/data
.js
' % content_base, video_id))
81 data = self._parse_xml(
83 r'CreateData\
(\s
*"(.+?)"', context, 'data
').replace(r"\'", "'"),
87 for asset in data.findall('.//asset'):
88 asset_url = asset.get('url')
89 if not asset_url or not asset_url.endswith('.mp4'):
91 asset_id = self._search_regex(
92 r'video_([^_]+)_', asset_url, 'asset id', default=None)
98 'url': content_base + asset_url,
101 return self.playlist_result(entries, video_id, title)
104 class SCTECourseIE(SCTEBaseIE):
105 _VALID_URL = r'https?://learning\.scte\.org/(?:mod/sub)?course/view\.php?.*?\bid=(?P<id>\d+)'
107 'url': 'https://learning.scte.org/mod/subcourse/view.php?id=31491',
108 'only_matching': True,
110 'url': 'https://learning.scte.org/course/view.php?id=3639',
111 'only_matching': True,
113 'url': 'https://learning.scte.org/course/view.php?id=3073',
114 'only_matching': True,
117 def _real_extract(self, url):
118 course_id = self._match_id(url)
120 webpage = self._download_webpage(url, course_id)
122 title = self._search_regex(
123 r'<h1>(.+?)</h1>', webpage, 'title', default=None)
126 for mobj in re.finditer(
131 https?
://learning\
.scte\
.org
/mod
/
132 (?P
<kind
>scorm|subcourse
)/view\
.php?
(?
:(?
!\
1).)*?
137 item_url = mobj.group('url')
140 ie = (SCTEIE.ie_key() if mobj.group('kind') == 'scorm'
141 else SCTECourseIE.ie_key())
142 entries.append(self.url_result(item_url, ie=ie))
144 return self.playlist_result(entries, course_id, title)