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': 4,
  15. }
  16. def _real_extract(self, url):
  17. m = re.match(self._VALID_URL, url)
  18. playlist_id = m.group('id')
  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'<li class="lecture-preview">\s*?<a target="_blank" href="([^"]+)">',
  27. webpage)
  28. entries = [self.url_result(u) for u in urls]
  29. return {
  30. '_type': 'playlist',
  31. 'id': playlist_id,
  32. 'title': title,
  33. 'description': description,
  34. 'entries': entries,
  35. }