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.

32 lines
1.0 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. def _real_extract(self, url):
  8. m = re.match(self._VALID_URL, url)
  9. playlist_id = m.group('id')
  10. webpage = self._download_webpage(url, playlist_id)
  11. title = self._html_search_regex(
  12. r'<h1 class="playlist-name"[^>]*?>(.*?)</h1>', webpage, u'title')
  13. description = self._html_search_regex(
  14. r'<p class="excerpt"[^>]*?>(.*?)</p>',
  15. webpage, u'description', fatal=False)
  16. urls = re.findall(
  17. r'<li class="lecture-preview">\s*?<a target="_blank" href="([^"]+)">',
  18. webpage)
  19. entries = [self.url_result(u) for u in urls]
  20. return {
  21. '_type': 'playlist',
  22. 'id': playlist_id,
  23. 'title': title,
  24. 'description': description,
  25. 'entries': entries,
  26. }