]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/khanacademy.py
408d00944ceb83e1551c12b5707031c961bb4f5d
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': '7021db7f2d47d4fff89b13177cb1e8f4',
21 'title': 'The one-time pad',
22 'description': 'The perfect cipher',
24 'uploader': 'Brit Cruise',
25 'upload_date': '20120411',
28 'url': 'https://www.khanacademy.org/math/applied-math/cryptography',
31 'title': 'Journey into cryptography',
32 'description': 'How have humans protected their secret messages through history? What has changed today?',
34 'playlist_mincount': 3,
37 def _real_extract(self
, url
):
38 m
= re
.match(self
._VALID
_URL
, url
)
39 video_id
= m
.group('id')
41 if m
.group('key') == 'video':
42 data
= self
._download
_json
(
43 'http://api.khanacademy.org/api/v1/videos/' + video_id
,
44 video_id
, 'Downloading video info')
46 upload_date
= unified_strdate(data
['date_added'])
47 uploader
= ', '.join(data
['author_names'])
49 '_type': 'url_transparent',
52 'title': data
['title'],
53 'thumbnail': data
['image_url'],
54 'duration': data
['duration'],
55 'description': data
['description'],
57 'upload_date': upload_date
,
61 data
= self
._download
_json
(
62 'http://api.khanacademy.org/api/v1/topic/' + video_id
,
63 video_id
, 'Downloading topic info')
72 for c
in data
['children'] if c
['kind'] in ('Video', 'Topic')]
77 'title': data
['title'],
78 'description': data
['description'],