1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-29 05:32:00 +00:00

[egghead:course] Improve (closes #13370)

This commit is contained in:
Sergey M․ 2017-07-09 17:28:42 +07:00
parent ed84454d35
commit 485cb37576
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -7,7 +7,7 @@ from .common import InfoExtractor
class EggheadCourseIE(InfoExtractor): class EggheadCourseIE(InfoExtractor):
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>[a-zA-Z_0-9-]+)' _VALID_URL = r'https://egghead\.io/courses/(?P<id>[^/?#&]+)'
_TEST = { _TEST = {
'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript', 'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript',
'playlist_count': 29, 'playlist_count': 29,
@ -20,18 +20,16 @@ class EggheadCourseIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
playlist_id = self._match_id(url) playlist_id = self._match_id(url)
api_url = 'https://egghead.io/api/v1/series/' + playlist_id
course = self._download_json(api_url, playlist_id)
title = course.get('title')
description = course.get('description')
lessons = course.get('lessons') course = self._download_json(
entries = [{'_type': 'url', 'ie_key': 'Wistia', 'url': 'wistia:' + l.get('wistia_id')} for l in lessons] 'https://egghead.io/api/v1/series/%s' % playlist_id, playlist_id)
return { entries = [
'_type': 'playlist', self.url_result(
'id': playlist_id, 'wistia:%s' % lesson['wistia_id'], ie='Wistia',
'title': title, video_id=lesson['wistia_id'], video_title=lesson.get('title'))
'description': description, for lesson in course['lessons'] if lesson.get('wistia_id')]
'entries': entries,
} return self.playlist_result(
entries, playlist_id, course.get('title'),
course.get('description'))