]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/egghead.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_str
15 class EggheadCourseIE(InfoExtractor
):
16 IE_DESC
= 'egghead.io course'
17 IE_NAME
= 'egghead:course'
18 _VALID_URL
= r
'https://egghead\.io/courses/(?P<id>[^/?#&]+)'
20 'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript',
24 'title': 'Professor Frisby Introduces Composable Functional JavaScript',
25 'description': 're:(?s)^This course teaches the ubiquitous.*You\'ll start composing functionality before you know it.$',
29 def _real_extract(self
, url
):
30 playlist_id
= self
._match
_id
(url
)
32 lessons
= self
._download
_json
(
33 'https://egghead.io/api/v1/series/%s/lessons' % playlist_id
,
34 playlist_id
, 'Downloading course lessons JSON')
37 for lesson
in lessons
:
38 lesson_url
= url_or_none(lesson
.get('http_url'))
41 lesson_id
= lesson
.get('id')
43 lesson_id
= compat_str(lesson_id
)
44 entries
.append(self
.url_result(
45 lesson_url
, ie
=EggheadLessonIE
.ie_key(), video_id
=lesson_id
))
47 course
= self
._download
_json
(
48 'https://egghead.io/api/v1/series/%s' % playlist_id
,
49 playlist_id
, 'Downloading course JSON', fatal
=False) or {}
51 playlist_id
= course
.get('id')
53 playlist_id
= compat_str(playlist_id
)
55 return self
.playlist_result(
56 entries
, playlist_id
, course
.get('title'),
57 course
.get('description'))
60 class EggheadLessonIE(InfoExtractor
):
61 IE_DESC
= 'egghead.io lesson'
62 IE_NAME
= 'egghead:lesson'
63 _VALID_URL
= r
'https://egghead\.io/(?:api/v1/)?lessons/(?P<id>[^/?#&]+)'
65 'url': 'https://egghead.io/lessons/javascript-linear-data-flow-with-container-style-types-box',
68 'display_id': 'javascript-linear-data-flow-with-container-style-types-box',
70 'title': 'Create linear data flow with container style types (Box)',
71 'description': 'md5:9aa2cdb6f9878ed4c39ec09e85a8150e',
72 'thumbnail': r
're:^https?:.*\.jpg$',
73 'timestamp': 1481296768,
74 'upload_date': '20161209',
77 'tags': ['javascript', 'free'],
80 'skip_download': True,
81 'format': 'bestvideo',
84 'url': 'https://egghead.io/api/v1/lessons/react-add-redux-to-a-react-application',
85 'only_matching': True,
88 def _real_extract(self
, url
):
89 display_id
= self
._match
_id
(url
)
91 lesson
= self
._download
_json
(
92 'https://egghead.io/api/v1/lessons/%s' % display_id
, display_id
)
94 lesson_id
= compat_str(lesson
['id'])
95 title
= lesson
['title']
98 for _
, format_url
in lesson
['media_urls'].items():
99 format_url
= url_or_none(format_url
)
102 ext
= determine_ext(format_url
)
104 formats
.extend(self
._extract
_m
3u8_formats
(
105 format_url
, lesson_id
, 'mp4', entry_protocol
='m3u8',
106 m3u8_id
='hls', fatal
=False))
108 formats
.extend(self
._extract
_mpd
_formats
(
109 format_url
, lesson_id
, mpd_id
='dash', fatal
=False))
114 self
._sort
_formats
(formats
)
118 'display_id': display_id
,
120 'description': lesson
.get('summary'),
121 'thumbnail': lesson
.get('thumb_nail'),
122 'timestamp': unified_timestamp(lesson
.get('published_at')),
123 'duration': int_or_none(lesson
.get('duration')),
124 'view_count': int_or_none(lesson
.get('plays_count')),
125 'tags': try_get(lesson
, lambda x
: x
['tag_list'], list),
127 lesson
, lambda x
: x
['series']['title'], compat_str
),