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