]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/academicearth.py
[nhl] Modernize
[yt-dlp.git] / youtube_dl / extractor / academicearth.py
CommitLineData
3798eadc 1from __future__ import unicode_literals
d90df974
PH
2import re
3
4from .common import InfoExtractor
d90df974
PH
5
6
7class AcademicEarthCourseIE(InfoExtractor):
9e57ce71 8 _VALID_URL = r'^https?://(?:www\.)?academicearth\.org/playlists/(?P<id>[^?#/]+)'
3798eadc 9 IE_NAME = 'AcademicEarth:Course'
d90df974
PH
10
11 def _real_extract(self, url):
12 m = re.match(self._VALID_URL, url)
13 playlist_id = m.group('id')
14
15 webpage = self._download_webpage(url, playlist_id)
16 title = self._html_search_regex(
9e57ce71 17 r'<h1 class="playlist-name"[^>]*?>(.*?)</h1>', webpage, u'title')
d90df974 18 description = self._html_search_regex(
9e57ce71 19 r'<p class="excerpt"[^>]*?>(.*?)</p>',
d90df974
PH
20 webpage, u'description', fatal=False)
21 urls = re.findall(
9e57ce71 22 r'<li class="lecture-preview">\s*?<a target="_blank" href="([^"]+)">',
d90df974
PH
23 webpage)
24 entries = [self.url_result(u) for u in urls]
25
26 return {
27 '_type': 'playlist',
28 'id': playlist_id,
29 'title': title,
30 'description': description,
31 'entries': entries,
32 }