You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.4 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class AcademicEarthCourseIE(InfoExtractor):
  5. _VALID_URL = r'^https?://(?:www\.)?academicearth\.org/playlists/(?P<id>[^?#/]+)'
  6. IE_NAME = 'AcademicEarth:Course'
  7. _TEST = {
  8. 'url': 'http://academicearth.org/playlists/laws-of-nature/',
  9. 'info_dict': {
  10. 'id': 'laws-of-nature',
  11. 'title': 'Laws of Nature',
  12. 'description': 'Introduce yourself to the laws of nature with these free online college lectures from Yale, Harvard, and MIT.',
  13. },
  14. 'playlist_count': 3,
  15. }
  16. def _real_extract(self, url):
  17. playlist_id = self._match_id(url)
  18. webpage = self._download_webpage(url, playlist_id)
  19. title = self._html_search_regex(
  20. r'<h1 class="playlist-name"[^>]*?>(.*?)</h1>', webpage, 'title')
  21. description = self._html_search_regex(
  22. r'<p class="excerpt"[^>]*?>(.*?)</p>',
  23. webpage, 'description', fatal=False)
  24. urls = re.findall(
  25. r'<li class="lecture-preview">\s*?<a target="_blank" href="([^"]+)">',
  26. webpage)
  27. entries = [self.url_result(u) for u in urls]
  28. return {
  29. '_type': 'playlist',
  30. 'id': playlist_id,
  31. 'title': title,
  32. 'description': description,
  33. 'entries': entries,
  34. }