]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/khanacademy.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
11 class KhanAcademyIE(InfoExtractor
):
12 _VALID_URL
= r
'^https?://(?:(?:www|api)\.)?khanacademy\.org/(?P<key>[^/]+)/(?:[^/]+/){,2}(?P<id>[^?#/]+)(?:$|[?#])'
13 IE_NAME
= 'KhanAcademy'
16 'url': 'http://www.khanacademy.org/video/one-time-pad',
17 'md5': '7b391cce85e758fb94f763ddc1bbb979',
21 'title': 'The one-time pad',
22 'description': 'The perfect cipher',
24 'uploader': 'Brit Cruise',
25 'uploader_id': 'khanacademy',
26 'upload_date': '20120411',
28 'add_ie': ['Youtube'],
30 'url': 'https://www.khanacademy.org/math/applied-math/cryptography',
33 'title': 'Journey into cryptography',
34 'description': 'How have humans protected their secret messages through history? What has changed today?',
36 'playlist_mincount': 3,
39 def _real_extract(self
, url
):
40 m
= re
.match(self
._VALID
_URL
, url
)
41 video_id
= m
.group('id')
43 if m
.group('key') == 'video':
44 data
= self
._download
_json
(
45 'http://api.khanacademy.org/api/v1/videos/' + video_id
,
46 video_id
, 'Downloading video info')
48 upload_date
= unified_strdate(data
['date_added'])
49 uploader
= ', '.join(data
['author_names'])
51 '_type': 'url_transparent',
54 'title': data
['title'],
55 'thumbnail': data
['image_url'],
56 'duration': data
['duration'],
57 'description': data
['description'],
59 'upload_date': upload_date
,
63 data
= self
._download
_json
(
64 'http://api.khanacademy.org/api/v1/topic/' + video_id
,
65 video_id
, 'Downloading topic info')
74 for c
in data
['children'] if c
['kind'] in ('Video', 'Topic')]
79 'title': data
['title'],
80 'description': data
['description'],