]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/pbs.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
8 class PBSIE(InfoExtractor
):
9 _VALID_URL
= r
'''(?x)https?://
12 video\.pbs\.org/(?:viralplayer|video)/(?P<id>[0-9]+)/? |
13 # Article with embedded player
14 (?:www\.)?pbs\.org/(?:[^/]+/){2,5}(?P<presumptive_id>[^/]+)/?(?:$|[?\#]) |
16 video\.pbs\.org/partnerplayer/(?P<player_id>[^/]+)/
21 'url': 'http://www.pbs.org/tpt/constitution-usa-peter-sagal/watch/a-more-perfect-union/',
22 'md5': 'ce1888486f0908d555a8093cac9a7362',
26 'title': 'A More Perfect Union',
27 'description': 'md5:ba0c207295339c8d6eced00b7c363c6a',
32 def _real_extract(self
, url
):
33 mobj
= re
.match(self
._VALID
_URL
, url
)
35 presumptive_id
= mobj
.group('presumptive_id')
36 display_id
= presumptive_id
38 webpage
= self
._download
_webpage
(url
, display_id
)
39 url
= self
._search
_regex
(
40 r
'<iframe\s+id=["\']partnerPlayer
["\'].*?\s+src=["\'](.*?
)["\']>',
41 webpage, 'player URL')
42 mobj = re.match(self._VALID_URL, url)
44 player_id = mobj.group('player_id')
46 display_id = player_id
48 player_page = self._download_webpage(
49 url, display_id, note='Downloading player page',
50 errnote='Could not download player page')
51 video_id = self._search_regex(
52 r'<div\s+id="video_([0-9]+)"', player_page, 'video ID')
54 video_id = mobj.group('id')
57 info_url = 'http://video.pbs.org/videoInfo/%s?format=json' % video_id
58 info = self._download_json(info_url, display_id)
62 'title': info['title'],
63 'url': info['alternate_encoding']['url'],
65 'description': info['program'].get('description'),
66 'thumbnail': info.get('image_url'),
67 'duration': info.get('duration'),