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