]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/egghead.py
1 from .common
import InfoExtractor
2 from ..compat
import compat_str
12 class EggheadBaseIE(InfoExtractor
):
13 def _call_api(self
, path
, video_id
, resource
, fatal
=True):
14 return self
._download
_json
(
15 'https://app.egghead.io/api/v1/' + path
,
16 video_id
, 'Downloading %s JSON' % resource
, fatal
=fatal
)
19 class EggheadCourseIE(EggheadBaseIE
):
20 IE_DESC
= 'egghead.io course'
21 IE_NAME
= 'egghead:course'
22 _VALID_URL
= r
'https://(?:app\.)?egghead\.io/(?:course|playlist)s/(?P<id>[^/?#&]+)'
24 'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript',
28 'title': 'Professor Frisby Introduces Composable Functional JavaScript',
29 'description': 're:(?s)^This course teaches the ubiquitous.*You\'ll start composing functionality before you know it.$',
32 'url': 'https://app.egghead.io/playlists/professor-frisby-introduces-composable-functional-javascript',
33 'only_matching': True,
36 def _real_extract(self
, url
):
37 playlist_id
= self
._match
_id
(url
)
38 series_path
= 'series/' + playlist_id
39 lessons
= self
._call
_api
(
40 series_path
+ '/lessons', playlist_id
, 'course lessons')
43 for lesson
in lessons
:
44 lesson_url
= url_or_none(lesson
.get('http_url'))
47 lesson_id
= lesson
.get('id')
49 lesson_id
= compat_str(lesson_id
)
50 entries
.append(self
.url_result(
51 lesson_url
, ie
=EggheadLessonIE
.ie_key(), video_id
=lesson_id
))
53 course
= self
._call
_api
(
54 series_path
, playlist_id
, 'course', False) or {}
56 playlist_id
= course
.get('id')
58 playlist_id
= compat_str(playlist_id
)
60 return self
.playlist_result(
61 entries
, playlist_id
, course
.get('title'),
62 course
.get('description'))
65 class EggheadLessonIE(EggheadBaseIE
):
66 IE_DESC
= 'egghead.io lesson'
67 IE_NAME
= 'egghead:lesson'
68 _VALID_URL
= r
'https://(?:app\.)?egghead\.io/(?:api/v1/)?lessons/(?P<id>[^/?#&]+)'
70 'url': 'https://egghead.io/lessons/javascript-linear-data-flow-with-container-style-types-box',
73 'display_id': 'javascript-linear-data-flow-with-container-style-types-box',
75 'title': 'Create linear data flow with container style types (Box)',
76 'description': 'md5:9aa2cdb6f9878ed4c39ec09e85a8150e',
77 'thumbnail': r
're:^https?:.*\.jpg$',
78 'timestamp': 1481296768,
79 'upload_date': '20161209',
85 'skip_download': True,
88 'url': 'https://egghead.io/api/v1/lessons/react-add-redux-to-a-react-application',
89 'only_matching': True,
91 'url': 'https://app.egghead.io/lessons/javascript-linear-data-flow-with-container-style-types-box',
92 'only_matching': True,
95 def _real_extract(self
, url
):
96 display_id
= self
._match
_id
(url
)
98 lesson
= self
._call
_api
(
99 'lessons/' + display_id
, display_id
, 'lesson')
101 lesson_id
= compat_str(lesson
['id'])
102 title
= lesson
['title']
105 for _
, format_url
in lesson
['media_urls'].items():
106 format_url
= url_or_none(format_url
)
109 ext
= determine_ext(format_url
)
111 formats
.extend(self
._extract
_m
3u8_formats
(
112 format_url
, lesson_id
, 'mp4', m3u8_id
='hls', fatal
=False))
114 formats
.extend(self
._extract
_mpd
_formats
(
115 format_url
, lesson_id
, mpd_id
='dash', fatal
=False))
123 'display_id': display_id
,
125 'description': lesson
.get('summary'),
126 'thumbnail': lesson
.get('thumb_nail'),
127 'timestamp': unified_timestamp(lesson
.get('published_at')),
128 'duration': int_or_none(lesson
.get('duration')),
129 'view_count': int_or_none(lesson
.get('plays_count')),
130 'tags': try_get(lesson
, lambda x
: x
['tag_list'], list),
132 lesson
, lambda x
: x
['series']['title'], compat_str
),