]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/pbs.py
Update changelog.
[youtubedl] / youtube_dl / extractor / pbs.py
1 import re
2 import json
3
4 from .common import InfoExtractor
5
6
7 class PBSIE(InfoExtractor):
8 _VALID_URL = r'https?://video.pbs.org/video/(?P<id>\d+)/?'
9
10 _TEST = {
11 u'url': u'http://video.pbs.org/video/2365006249/',
12 u'file': u'2365006249.mp4',
13 u'md5': 'ce1888486f0908d555a8093cac9a7362',
14 u'info_dict': {
15 u'title': u'A More Perfect Union',
16 u'description': u'md5:ba0c207295339c8d6eced00b7c363c6a',
17 u'duration': 3190,
18 },
19 }
20
21 def _real_extract(self, url):
22 mobj = re.match(self._VALID_URL, url)
23 video_id = mobj.group('id')
24 info_url = 'http://video.pbs.org/videoInfo/%s?format=json' % video_id
25 info_page = self._download_webpage(info_url, video_id)
26 info =json.loads(info_page)
27 return {'id': video_id,
28 'title': info['title'],
29 'url': info['alternate_encoding']['url'],
30 'ext': 'mp4',
31 'description': info['program'].get('description'),
32 'thumbnail': info.get('image_url'),
33 'duration': info.get('duration'),
34 }