]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/academicearth.py
Merge remote-tracking branch 'origin/master'
[youtube-dl.git] / youtube_dl / extractor / academicearth.py
1 import re
2
3 from .common import InfoExtractor
4
5
6 class AcademicEarthCourseIE(InfoExtractor):
7     _VALID_URL = r'^https?://(?:www\.)?academicearth\.org/(?:courses|playlists)/(?P<id>[^?#/]+)'
8     IE_NAME = u'AcademicEarth:Course'
9
10     def _real_extract(self, url):
11         m = re.match(self._VALID_URL, url)
12         playlist_id = m.group('id')
13
14         webpage = self._download_webpage(url, playlist_id)
15         title = self._html_search_regex(
16             r'<h1 class="playlist-name">(.*?)</h1>', webpage, u'title')
17         description = self._html_search_regex(
18             r'<p class="excerpt">(.*?)</p>',
19             webpage, u'description', fatal=False)
20         urls = re.findall(
21             r'<h3 class="lecture-title"><a target="_blank" href="([^"]+)">',
22             webpage)
23         entries = [self.url_result(u) for u in urls]
24
25         return {
26             '_type': 'playlist',
27             'id': playlist_id,
28             'title': title,
29             'description': description,
30             'entries': entries,
31         }