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.

39 lines
1.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class EggheadCourseIE(InfoExtractor):
  6. IE_DESC = 'egghead.io course'
  7. IE_NAME = 'egghead:course'
  8. _VALID_URL = r'https://egghead\.io/courses/(?P<id>[a-zA-Z_0-9-]+)'
  9. _TEST = {
  10. 'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript',
  11. 'playlist_count': 29,
  12. 'info_dict': {
  13. 'id': 'professor-frisby-introduces-composable-functional-javascript',
  14. 'title': 'Professor Frisby Introduces Composable Functional JavaScript',
  15. 'description': 're:(?s)^This course teaches the ubiquitous.*You\'ll start composing functionality before you know it.$',
  16. },
  17. }
  18. def _real_extract(self, url):
  19. playlist_id = self._match_id(url)
  20. webpage = self._download_webpage(url, playlist_id)
  21. title = self._html_search_regex(r'<h1 class="title">([^<]+)</h1>', webpage, 'title')
  22. ul = self._search_regex(r'(?s)<ul class="series-lessons-list">(.*?)</ul>', webpage, 'session list')
  23. found = re.findall(r'(?s)<a class="[^"]*"\s*href="([^"]+)">\s*<li class="item', ul)
  24. entries = [self.url_result(m) for m in found]
  25. return {
  26. '_type': 'playlist',
  27. 'id': playlist_id,
  28. 'title': title,
  29. 'description': self._og_search_description(webpage),
  30. 'entries': entries,
  31. }