]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/academicearth.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / 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/playlists/(?P<id>[^?#/]+)'
8 IE_NAME = 'AcademicEarth:Course'
9 _TEST = {
10 'url': 'http://academicearth.org/playlists/laws-of-nature/',
11 'info_dict': {
12 'id': 'laws-of-nature',
13 'title': 'Laws of Nature',
14 'description': 'Introduce yourself to the laws of nature with these free online college lectures from Yale, Harvard, and MIT.',
15 },
16 'playlist_count': 3,
17 }
18
19 def _real_extract(self, url):
20 playlist_id = self._match_id(url)
21
22 webpage = self._download_webpage(url, playlist_id)
23 title = self._html_search_regex(
24 r'<h1 class="playlist-name"[^>]*?>(.*?)</h1>', webpage, 'title')
25 description = self._html_search_regex(
26 r'<p class="excerpt"[^>]*?>(.*?)</p>',
27 webpage, 'description', fatal=False)
28 urls = re.findall(
29 r'<li class="lecture-preview">\s*?<a target="_blank" href="([^"]+)">',
30 webpage)
31 entries = [self.url_result(u) for u in urls]
32
33 return {
34 '_type': 'playlist',
35 'id': playlist_id,
36 'title': title,
37 'description': description,
38 'entries': entries,
39 }