aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/pbs.py
diff options
context:
space:
mode:
authorPierre Rudloff <pierre@rudloff.pro>2013-08-22 12:52:05 +0200
committerPierre Rudloff <pierre@rudloff.pro>2013-08-22 12:52:05 +0200
commit8d212e604a86da3c924ab15fe8045ab748a8183d (patch)
tree5bc5588e5bbe7f8dad3fb1d0bbba354f2fb9e90c /youtube_dl/extractor/pbs.py
parent943f7f7a399c6fb3006eb2bd68070f28a272171f (diff)
parent063fcc9676718fc4395b92d6e9665e7f3e9c8156 (diff)
Merge remote-tracking branch 'upstream/master'
Conflicts: youtube_dl/extractor/jeuxvideo.py
Diffstat (limited to 'youtube_dl/extractor/pbs.py')
-rw-r--r--youtube_dl/extractor/pbs.py34
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'),
+ }