Compare commits

..

No commits in common. "b111a64135244b73b86a1720e9a5212e726afcbf" and "c11f7cf9bd6ef239f25e7fb9c54e092ae1490e2d" have entirely different histories.

View File

@ -12,14 +12,7 @@ from ..utils import (
) )
class EggheadBaseIE(InfoExtractor): class EggheadCourseIE(InfoExtractor):
def _call_api(self, path, video_id, resource, fatal=True):
return self._download_json(
'https://app.egghead.io/api/v1/' + path,
video_id, 'Downloading %s JSON' % resource, fatal=fatal)
class EggheadCourseIE(EggheadBaseIE):
IE_DESC = 'egghead.io course' IE_DESC = 'egghead.io course'
IE_NAME = 'egghead:course' IE_NAME = 'egghead:course'
_VALID_URL = r'https://egghead\.io/courses/(?P<id>[^/?#&]+)' _VALID_URL = r'https://egghead\.io/courses/(?P<id>[^/?#&]+)'
@ -35,9 +28,10 @@ class EggheadCourseIE(EggheadBaseIE):
def _real_extract(self, url): def _real_extract(self, url):
playlist_id = self._match_id(url) playlist_id = self._match_id(url)
series_path = 'series/' + playlist_id
lessons = self._call_api( lessons = self._download_json(
series_path + '/lessons', playlist_id, 'course lessons') 'https://egghead.io/api/v1/series/%s/lessons' % playlist_id,
playlist_id, 'Downloading course lessons JSON')
entries = [] entries = []
for lesson in lessons: for lesson in lessons:
@ -50,8 +44,9 @@ class EggheadCourseIE(EggheadBaseIE):
entries.append(self.url_result( entries.append(self.url_result(
lesson_url, ie=EggheadLessonIE.ie_key(), video_id=lesson_id)) lesson_url, ie=EggheadLessonIE.ie_key(), video_id=lesson_id))
course = self._call_api( course = self._download_json(
series_path, playlist_id, 'course', False) or {} 'https://egghead.io/api/v1/series/%s' % playlist_id,
playlist_id, 'Downloading course JSON', fatal=False) or {}
playlist_id = course.get('id') playlist_id = course.get('id')
if playlist_id: if playlist_id:
@ -62,7 +57,7 @@ class EggheadCourseIE(EggheadBaseIE):
course.get('description')) course.get('description'))
class EggheadLessonIE(EggheadBaseIE): class EggheadLessonIE(InfoExtractor):
IE_DESC = 'egghead.io lesson' IE_DESC = 'egghead.io lesson'
IE_NAME = 'egghead:lesson' IE_NAME = 'egghead:lesson'
_VALID_URL = r'https://egghead\.io/(?:api/v1/)?lessons/(?P<id>[^/?#&]+)' _VALID_URL = r'https://egghead\.io/(?:api/v1/)?lessons/(?P<id>[^/?#&]+)'
@ -79,7 +74,7 @@ class EggheadLessonIE(EggheadBaseIE):
'upload_date': '20161209', 'upload_date': '20161209',
'duration': 304, 'duration': 304,
'view_count': 0, 'view_count': 0,
'tags': 'count:2', 'tags': ['javascript', 'free'],
}, },
'params': { 'params': {
'skip_download': True, 'skip_download': True,
@ -93,8 +88,8 @@ class EggheadLessonIE(EggheadBaseIE):
def _real_extract(self, url): def _real_extract(self, url):
display_id = self._match_id(url) display_id = self._match_id(url)
lesson = self._call_api( lesson = self._download_json(
'lessons/' + display_id, display_id, 'lesson') 'https://egghead.io/api/v1/lessons/%s' % display_id, display_id)
lesson_id = compat_str(lesson['id']) lesson_id = compat_str(lesson['id'])
title = lesson['title'] title = lesson['title']