diff options
author | Ismael Mejia <iemejia@gmail.com> | 2013-08-22 23:29:36 +0200 |
---|---|---|
committer | Ismael Mejia <iemejia@gmail.com> | 2013-08-22 23:29:36 +0200 |
commit | 18b4e04f1c663e0ea695f6501b860f85af9d7ca1 (patch) | |
tree | d60ebbf51b8c50f808c6c251fc6c02547052a9dc /youtube_dl/extractor/pbs.py | |
parent | d80a064eff4fe2416f9db36b07f1e2ca641f1334 (diff) | |
parent | 1865ed31b955795f9859df5c1c400d172ae9a28a (diff) |
Merge branch 'master' into subtitles_rework
Diffstat (limited to 'youtube_dl/extractor/pbs.py')
-rw-r--r-- | youtube_dl/extractor/pbs.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/youtube_dl/extractor/pbs.py b/youtube_dl/extractor/pbs.py new file mode 100644 index 000000000..65462d867 --- /dev/null +++ b/youtube_dl/extractor/pbs.py @@ -0,0 +1,34 @@ +import re +import json + +from .common import InfoExtractor + + +class PBSIE(InfoExtractor): + _VALID_URL = r'https?://video.pbs.org/video/(?P<id>\d+)/?' + + _TEST = { + u'url': u'http://video.pbs.org/video/2365006249/', + u'file': u'2365006249.mp4', + u'md5': 'ce1888486f0908d555a8093cac9a7362', + u'info_dict': { + u'title': u'A More Perfect Union', + u'description': u'md5:ba0c207295339c8d6eced00b7c363c6a', + u'duration': 3190, + }, + } + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + info_url = 'http://video.pbs.org/videoInfo/%s?format=json' % video_id + info_page = self._download_webpage(info_url, video_id) + info =json.loads(info_page) + return {'id': video_id, + 'title': info['title'], + 'url': info['alternate_encoding']['url'], + 'ext': 'mp4', + 'description': info['program'].get('description'), + 'thumbnail': info.get('image_url'), + 'duration': info.get('duration'), + } |