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.

30 lines
1.1 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class CBSSportsIE(InfoExtractor):
  5. _VALID_URL = r'http://www\.cbssports\.com/video/player/(?P<section>[^/]+)/(?P<id>[^/]+)'
  6. _TEST = {
  7. 'url': 'http://www.cbssports.com/video/player/tennis/318462531970/0/us-open-flashbacks-1990s',
  8. 'info_dict': {
  9. 'id': '_d5_GbO8p1sT',
  10. 'ext': 'flv',
  11. 'title': 'US Open flashbacks: 1990s',
  12. 'description': 'Bill Macatee relives the best moments in US Open history from the 1990s.',
  13. },
  14. }
  15. def _real_extract(self, url):
  16. mobj = re.match(self._VALID_URL, url)
  17. section = mobj.group('section')
  18. video_id = mobj.group('id')
  19. all_videos = self._download_json(
  20. 'http://www.cbssports.com/data/video/player/getVideos/%s?as=json' % section,
  21. video_id)
  22. # The json file contains the info of all the videos in the section
  23. video_info = next(v for v in all_videos if v['pcid'] == video_id)
  24. return self.url_result('theplatform:%s' % video_info['pid'], 'ThePlatform')