]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/khanacademy.py
772bb5671e8f027b2723b54c00794217f6d94edb
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
11 class KhanAcademyIE(InfoExtractor
):
12 _VALID_URL
= r
'^https?://(?:www\.)?khanacademy\.org/(?P<key>[^/]+)/(?:[^/]+/){,2}(?P<id>[^?#/]+)(?:$|[?#])'
13 IE_NAME
= 'KhanAcademy'
16 'url': 'http://www.khanacademy.org/video/one-time-pad',
17 'file': 'one-time-pad.mp4',
18 'md5': '7021db7f2d47d4fff89b13177cb1e8f4',
20 'title': 'The one-time pad',
21 'description': 'The perfect cipher',
23 'uploader': 'Brit Cruise',
24 'upload_date': '20120411',
28 def _real_extract(self
, url
):
29 m
= re
.match(self
._VALID
_URL
, url
)
30 video_id
= m
.group('id')
32 if m
.group('key') == 'video':
33 data
= self
._download
_json
(
34 'http://api.khanacademy.org/api/v1/videos/' + video_id
,
35 video_id
, 'Downloading video info')
37 upload_date
= unified_strdate(data
['date_added'])
38 uploader
= ', '.join(data
['author_names'])
40 '_type': 'url_transparent',
43 'title': data
['title'],
44 'thumbnail': data
['image_url'],
45 'duration': data
['duration'],
46 'description': data
['description'],
48 'upload_date': upload_date
,
52 data
= self
._download
_json
(
53 'http://api.khanacademy.org/api/v1/topic/' + video_id
,
54 video_id
, 'Downloading topic info')
63 for c
in data
['children'] if c
['kind'] in ('Video', 'Topic')]
68 'title': data
['title'],
69 'description': data
['description'],