-# coding: utf-8
-from __future__ import unicode_literals
-
import re
from .common import InfoExtractor
-
-from ..compat import (
- compat_urlparse,
-)
-
+from ..compat import compat_urlparse
from ..utils import (
+ ExtractorError,
+ clean_html,
+ int_or_none,
urlencode_postdata,
urljoin,
- int_or_none,
- clean_html,
- ExtractorError
)
def _real_extract(self, url):
- video_id = self._match_id(url)
- course = self._search_regex(self._VALID_URL, url, 'post url', group='course_name')
+ course, video_id = self._match_valid_url(url).group('course_name', 'id')
video_url = self._VIDEO_URL % (course, video_id)
video_dict = self._download_json(video_url, video_id, 'Searching for videos')
formats = []
for video_obj in video_dict:
- video_url_m3u8 = video_obj.get('link')
+ video_url_m3u8 = video_obj.get('mp4')
video_format = self._extract_m3u8_formats(
video_url_m3u8, None, 'mp4', entry_protocol='m3u8_native',
m3u8_id='hls', fatal=False)
f['height'] = int('720' if m.group('res') == 'hd' else '480')
formats.extend(video_format)
- self._sort_formats(formats)
-
return {
'id': video_id,
'title': video_title,
"formats": formats
}
- def _real_initialize(self):
- self._login()
-
- def _login(self):
- username, password = self._get_login_info()
- if username is None:
- return
- pass
+ def _perform_login(self, username, password):
login_page = self._download_webpage(
self._LOGIN_URL, None, 'Downloading login popup')
raise ExtractorError('Unable to log in')
-class AluraCourseIE(AluraIE):
+class AluraCourseIE(AluraIE): # XXX: Do not subclass from concrete IE
_VALID_URL = r'https?://(?:cursos\.)?alura\.com\.br/course/(?P<id>[^/]+)'
_LOGIN_URL = 'https://cursos.alura.com.br/loginForm?urlAfterLogin=/loginForm'