]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cbsnews.py
17bb9af4fe2a8a0066611a2bbc2d090ad7cf5e30
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
11 class CBSNewsIE(CBSIE
):
14 _VALID_URL
= r
'https?://(?:www\.)?cbsnews\.com/(?:news|videos)/(?P<id>[\da-z_-]+)'
18 'url': 'http://www.cbsnews.com/news/tesla-and-spacex-elon-musks-industrial-empire/',
20 'id': 'tesla-and-spacex-elon-musks-industrial-empire',
22 'title': 'Tesla and SpaceX: Elon Musk\'s industrial empire',
23 'thumbnail': 'http://beta.img.cbsnews.com/i/2014/03/30/60147937-2f53-4565-ad64-1bdd6eb64679/60-0330-pelley-640x360.jpg',
28 'skip_download': True,
30 'skip': 'Subscribers only',
33 'url': 'http://www.cbsnews.com/videos/fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack/',
35 'id': 'SNJBOYzXiWBOvaLsdzwH8fmtP1SCd91Y',
37 'title': 'Fort Hood shooting: Army downplays mental illness as cause of attack',
38 'description': 'md5:4a6983e480542d8b333a947bfc64ddc7',
39 'upload_date': '20140404',
40 'timestamp': 1396650660,
41 'uploader': 'CBSI-NEW',
42 'thumbnail': r
're:^https?://.*\.jpg$',
52 'skip_download': True,
57 def _real_extract(self
, url
):
58 video_id
= self
._match
_id
(url
)
60 webpage
= self
._download
_webpage
(url
, video_id
)
62 video_info
= self
._parse
_json
(self
._html
_search
_regex
(
63 r
'(?:<ul class="media-list items" id="media-related-items"><li data-video-info|<div id="cbsNewsVideoPlayer" data-video-player-options)=\'({.+?
})\'',
64 webpage, 'video JSON info
'), video_id)
66 item = video_info['item
'] if 'item
' in video_info else video_info
67 guid = item['mpxRefId
']
68 return self._extract_video_info(guid)
71 class CBSNewsLiveVideoIE(InfoExtractor):
72 IE_NAME = 'cbsnews
:livevideo
'
73 IE_DESC = 'CBS News Live Videos
'
74 _VALID_URL = r'https?
://(?
:www\
.)?cbsnews\
.com
/live
/video
/(?P
<id>[^
/?
#]+)'
76 # Live videos get deleted soon. See http://www.cbsnews.com/live/ for the latest examples
78 'url': 'http://www.cbsnews.com/live/video/clinton-sanders-prepare-to-face-off-in-nh/',
80 'id': 'clinton-sanders-prepare-to-face-off-in-nh',
82 'title': 'Clinton, Sanders Prepare To Face Off In NH',
88 def _real_extract(self
, url
):
89 display_id
= self
._match
_id
(url
)
91 video_info
= self
._download
_json
(
92 'http://feeds.cbsn.cbsnews.com/rundown/story', display_id
, query
={
94 'dvr_slug': display_id
,
97 formats
= self
._extract
_akamai
_formats
(video_info
['url'], display_id
)
98 self
._sort
_formats
(formats
)
102 'display_id': display_id
,
103 'title': video_info
['headline'],
104 'thumbnail': video_info
.get('thumbnail_url_hd') or video_info
.get('thumbnail_url_sd'),
105 'duration': parse_duration(video_info
.get('segmentDur')),