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.

37 lines
1.4 KiB

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