You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.3 KiB

  1. import re
  2. import json
  3. from .common import InfoExtractor
  4. class BrightcoveIE(InfoExtractor):
  5. _VALID_URL = r'http://.*brightcove\.com/.*\?(?P<query>.*videoPlayer=(?P<id>\d*).*)'
  6. def _real_extract(self, url):
  7. mobj = re.match(self._VALID_URL, url)
  8. query = mobj.group('query')
  9. video_id = mobj.group('id')
  10. request_url = 'http://c.brightcove.com/services/viewer/htmlFederated?%s' % query
  11. webpage = self._download_webpage(request_url, video_id)
  12. self.report_extraction(video_id)
  13. info = self._search_regex(r'var experienceJSON = ({.*?});', webpage, 'json')
  14. info = json.loads(info)['data']
  15. video_info = info['programmedContent']['videoPlayer']['mediaDTO']
  16. renditions = video_info['renditions']
  17. renditions = sorted(renditions, key=lambda r: r['size'])
  18. best_format = renditions[-1]
  19. return {'id': video_id,
  20. 'title': video_info['displayName'],
  21. 'url': best_format['defaultURL'],
  22. 'ext': 'mp4',
  23. 'description': video_info.get('shortDescription'),
  24. 'thumbnail': video_info.get('videoStillURL') or video_info.get('thumbnailURL'),
  25. 'uploader': video_info.get('publisherName'),
  26. }