]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/brightcove.py
4 from .common
import InfoExtractor
6 class BrightcoveIE(InfoExtractor
):
7 _VALID_URL
= r
'http://.*brightcove\.com/.*\?(?P<query>.*videoPlayer=(?P<id>\d*).*)'
9 def _real_extract(self
, url
):
10 mobj
= re
.match(self
._VALID
_URL
, url
)
11 query
= mobj
.group('query')
12 video_id
= mobj
.group('id')
14 request_url
= 'http://c.brightcove.com/services/viewer/htmlFederated?%s' % query
15 webpage
= self
._download
_webpage
(request_url
, video_id
)
17 self
.report_extraction(video_id
)
18 info
= self
._search
_regex
(r
'var experienceJSON = ({.*?});', webpage
, 'json')
19 info
= json
.loads(info
)['data']
20 video_info
= info
['programmedContent']['videoPlayer']['mediaDTO']
21 renditions
= video_info
['renditions']
22 renditions
= sorted(renditions
, key
=lambda r
: r
['size'])
23 best_format
= renditions
[-1]
25 return {'id': video_id
,
26 'title': video_info
['displayName'],
27 'url': best_format
['defaultURL'],
29 'description': video_info
.get('shortDescription'),
30 'thumbnail': video_info
.get('videoStillURL') or video_info
.get('thumbnailURL'),
31 'uploader': video_info
.get('publisherName'),