~ubuntu-branches/ubuntu/vivid/youtube-dl/vivid

« back to all changes in this revision

Viewing changes to youtube_dl/extractor/cbssports.py

  • Committer: Package Import Robot
  • Author(s): Rogério Brito
  • Date: 2015-03-01 02:12:13 UTC
  • mfrom: (44.1.24 sid)
  • Revision ID: package-import@ubuntu.com-20150301021213-8w657cue71kp77sz
Tags: 2015.02.28-1
Imported Upstream version 2015.02.28. Closes: #778765.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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')