[cleanup] Make more playlist entries lazy (#11763)
[yt-dlp.git] / yt_dlp / extractor / academicearth.py
blobb997a02885e45c3a3dfca68b07ac777a5338ae2a
1 import re
3 from .common import InfoExtractor
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.',
16 'playlist_count': 3,
19 def _real_extract(self, url):
20 playlist_id = self._match_id(url)
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]
33 return {
34 '_type': 'playlist',
35 'id': playlist_id,
36 'title': title,
37 'description': description,
38 'entries': entries,