]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/academicearth.py
Einthusan Add new extractor
[youtube-dl.git] / youtube_dl / extractor / academicearth.py
1 from __future__ import unicode_literals
2 import re
3
4 from .common import InfoExtractor
5
6
7 class AcademicEarthCourseIE(InfoExtractor):
8     _VALID_URL = r'^https?://(?:www\.)?academicearth\.org/playlists/(?P<id>[^?#/]+)'
9     IE_NAME = 'AcademicEarth:Course'
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(
17             r'<h1 class="playlist-name"[^>]*?>(.*?)</h1>', webpage, u'title')
18         description = self._html_search_regex(
19             r'<p class="excerpt"[^>]*?>(.*?)</p>',
20             webpage, u'description', fatal=False)
21         urls = re.findall(
22             r'<li class="lecture-preview">\s*?<a target="_blank" href="([^"]+)">',
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         }