]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/egghead.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_str
15 class EggheadBaseIE(InfoExtractor
):
16 def _call_api(self
, path
, video_id
, resource
, fatal
=True):
17 return self
._download
_json
(
18 'https://app.egghead.io/api/v1/' + path
,
19 video_id
, 'Downloading %s JSON' % resource
, fatal
=fatal
)
22 class EggheadCourseIE(EggheadBaseIE
):
23 IE_DESC
= 'egghead.io course'
24 IE_NAME
= 'egghead:course'
25 _VALID_URL
= r
'https://(?:app\.)?egghead\.io/(?:course|playlist)s/(?P<id>[^/?#&]+)'
27 'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript',
31 'title': 'Professor Frisby Introduces Composable Functional JavaScript',
32 'description': 're:(?s)^This course teaches the ubiquitous.*You\'ll start composing functionality before you know it.$',
35 'url': 'https://app.egghead.io/playlists/professor-frisby-introduces-composable-functional-javascript',
36 'only_matching': True,
39 def _real_extract(self
, url
):
40 playlist_id
= self
._match
_id
(url
)
41 series_path
= 'series/' + playlist_id
42 lessons
= self
._call
_api
(
43 series_path
+ '/lessons', playlist_id
, 'course lessons')
46 for lesson
in lessons
:
47 lesson_url
= url_or_none(lesson
.get('http_url'))
50 lesson_id
= lesson
.get('id')
52 lesson_id
= compat_str(lesson_id
)
53 entries
.append(self
.url_result(
54 lesson_url
, ie
=EggheadLessonIE
.ie_key(), video_id
=lesson_id
))
56 course
= self
._call
_api
(
57 series_path
, playlist_id
, 'course', False) or {}
59 playlist_id
= course
.get('id')
61 playlist_id
= compat_str(playlist_id
)
63 return self
.playlist_result(
64 entries
, playlist_id
, course
.get('title'),
65 course
.get('description'))
68 class EggheadLessonIE(EggheadBaseIE
):
69 IE_DESC
= 'egghead.io lesson'
70 IE_NAME
= 'egghead:lesson'
71 _VALID_URL
= r
'https://(?:app\.)?egghead\.io/(?:api/v1/)?lessons/(?P<id>[^/?#&]+)'
73 'url': 'https://egghead.io/lessons/javascript-linear-data-flow-with-container-style-types-box',
76 'display_id': 'javascript-linear-data-flow-with-container-style-types-box',
78 'title': 'Create linear data flow with container style types (Box)',
79 'description': 'md5:9aa2cdb6f9878ed4c39ec09e85a8150e',
80 'thumbnail': r
're:^https?:.*\.jpg$',
81 'timestamp': 1481296768,
82 'upload_date': '20161209',
88 'skip_download': True,
89 'format': 'bestvideo',
92 'url': 'https://egghead.io/api/v1/lessons/react-add-redux-to-a-react-application',
93 'only_matching': True,
95 'url': 'https://app.egghead.io/lessons/javascript-linear-data-flow-with-container-style-types-box',
96 'only_matching': True,
99 def _real_extract(self
, url
):
100 display_id
= self
._match
_id
(url
)
102 lesson
= self
._call
_api
(
103 'lessons/' + display_id
, display_id
, 'lesson')
105 lesson_id
= compat_str(lesson
['id'])
106 title
= lesson
['title']
109 for _
, format_url
in lesson
['media_urls'].items():
110 format_url
= url_or_none(format_url
)
113 ext
= determine_ext(format_url
)
115 formats
.extend(self
._extract
_m
3u8_formats
(
116 format_url
, lesson_id
, 'mp4', m3u8_id
='hls', fatal
=False))
118 formats
.extend(self
._extract
_mpd
_formats
(
119 format_url
, lesson_id
, mpd_id
='dash', fatal
=False))
124 self
._sort
_formats
(formats
)
128 'display_id': display_id
,
130 'description': lesson
.get('summary'),
131 'thumbnail': lesson
.get('thumb_nail'),
132 'timestamp': unified_timestamp(lesson
.get('published_at')),
133 'duration': int_or_none(lesson
.get('duration')),
134 'view_count': int_or_none(lesson
.get('plays_count')),
135 'tags': try_get(lesson
, lambda x
: x
['tag_list'], list),
137 lesson
, lambda x
: x
['series']['title'], compat_str
),