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.

84 lines
3.0 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. try_get,
  7. unified_timestamp,
  8. )
  9. class EggheadCourseIE(InfoExtractor):
  10. IE_DESC = 'egghead.io course'
  11. IE_NAME = 'egghead:course'
  12. _VALID_URL = r'https://egghead\.io/courses/(?P<id>[^/?#&]+)'
  13. _TEST = {
  14. 'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript',
  15. 'playlist_count': 29,
  16. 'info_dict': {
  17. 'id': 'professor-frisby-introduces-composable-functional-javascript',
  18. 'title': 'Professor Frisby Introduces Composable Functional JavaScript',
  19. 'description': 're:(?s)^This course teaches the ubiquitous.*You\'ll start composing functionality before you know it.$',
  20. },
  21. }
  22. def _real_extract(self, url):
  23. playlist_id = self._match_id(url)
  24. course = self._download_json(
  25. 'https://egghead.io/api/v1/series/%s' % playlist_id, playlist_id)
  26. entries = [
  27. self.url_result(
  28. 'wistia:%s' % lesson['wistia_id'], ie='Wistia',
  29. video_id=lesson['wistia_id'], video_title=lesson.get('title'))
  30. for lesson in course['lessons'] if lesson.get('wistia_id')]
  31. return self.playlist_result(
  32. entries, playlist_id, course.get('title'),
  33. course.get('description'))
  34. class EggheadLessonIE(InfoExtractor):
  35. IE_DESC = 'egghead.io lesson'
  36. IE_NAME = 'egghead:lesson'
  37. _VALID_URL = r'https://egghead\.io/lessons/(?P<id>[^/?#&]+)'
  38. _TEST = {
  39. 'url': 'https://egghead.io/lessons/javascript-linear-data-flow-with-container-style-types-box',
  40. 'info_dict': {
  41. 'id': 'fv5yotjxcg',
  42. 'ext': 'mp4',
  43. 'title': 'Create linear data flow with container style types (Box)',
  44. 'description': 'md5:9aa2cdb6f9878ed4c39ec09e85a8150e',
  45. 'thumbnail': r're:^https?:.*\.jpg$',
  46. 'timestamp': 1481296768,
  47. 'upload_date': '20161209',
  48. 'duration': 304,
  49. 'view_count': 0,
  50. 'tags': ['javascript', 'free'],
  51. },
  52. 'params': {
  53. 'skip_download': True,
  54. },
  55. }
  56. def _real_extract(self, url):
  57. lesson_id = self._match_id(url)
  58. lesson = self._download_json(
  59. 'https://egghead.io/api/v1/lessons/%s' % lesson_id, lesson_id)
  60. return {
  61. '_type': 'url_transparent',
  62. 'ie_key': 'Wistia',
  63. 'url': 'wistia:%s' % lesson['wistia_id'],
  64. 'id': lesson['wistia_id'],
  65. 'title': lesson.get('title'),
  66. 'description': lesson.get('summary'),
  67. 'thumbnail': lesson.get('thumb_nail'),
  68. 'timestamp': unified_timestamp(lesson.get('published_at')),
  69. 'duration': int_or_none(lesson.get('duration')),
  70. 'view_count': int_or_none(lesson.get('plays_count')),
  71. 'tags': try_get(lesson, lambda x: x['tag_list'], list),
  72. }