]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cbsnews.py
51df15faca995d8055361fccc8dc74a290e806d9
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_-]+)'
19 'url': 'http://www.cbsnews.com/news/artificial-intelligence-positioned-to-be-a-game-changer/',
21 'id': '_B6Ga3VJrI4iQNKsir_cdFo9Re_YJHE_',
23 'title': 'Artificial Intelligence',
24 'description': 'md5:8818145f9974431e0fb58a1b8d69613c',
25 'thumbnail': r
're:^https?://.*\.jpg$',
27 'uploader': 'CBSI-NEW',
28 'timestamp': 1498431900,
29 'upload_date': '20170625',
33 'skip_download': True,
37 'url': 'http://www.cbsnews.com/videos/fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack/',
39 'id': 'SNJBOYzXiWBOvaLsdzwH8fmtP1SCd91Y',
41 'title': 'Fort Hood shooting: Army downplays mental illness as cause of attack',
42 'description': 'md5:4a6983e480542d8b333a947bfc64ddc7',
43 'upload_date': '20140404',
44 'timestamp': 1396650660,
45 'uploader': 'CBSI-NEW',
46 'thumbnail': r
're:^https?://.*\.jpg$',
56 'skip_download': True,
61 'url': 'http://www.cbsnews.com/news/maria-ridulph-murder-will-the-nations-oldest-cold-case-to-go-to-trial-ever-get-solved/',
63 'id': 'QpM5BJjBVEAUFi7ydR9LusS69DPLqPJ1',
65 'title': 'Cold as Ice',
66 'description': 'Can a childhood memory of a friend\'s murder solve a 1957 cold case? "48 Hours" correspondent Erin Moriarty has the latest.',
67 'upload_date': '20170604',
68 'timestamp': 1496538000,
69 'uploader': 'CBSI-NEW',
72 'skip_download': True,
77 def _real_extract(self
, url
):
78 video_id
= self
._match
_id
(url
)
80 webpage
= self
._download
_webpage
(url
, video_id
)
82 video_info
= self
._parse
_json
(self
._html
_search
_regex
(
83 r
'(?:<ul class="media-list items" id="media-related-items"[^>]*><li data-video-info|<div id="cbsNewsVideoPlayer" data-video-player-options)=\'({.+?
})\'',
84 webpage, 'video JSON info
', default='{}'), video_id, fatal=False)
87 item = video_info['item
'] if 'item
' in video_info else video_info
89 state = self._parse_json(self._search_regex(
90 r'data
-cbsvideoui
-options
=(["\'])(?P<json>{.+?})\1', webpage,
91 'playlist JSON info', group='json'), video_id)['state']
92 item = state['playlist'][state['pid']]
94 return self._extract_video_info(item['mpxRefId'], 'cbsnews')
97 class CBSNewsLiveVideoIE(InfoExtractor):
98 IE_NAME = 'cbsnews:livevideo'
99 IE_DESC = 'CBS News Live Videos'
100 _VALID_URL = r'https?://(?:www\.)?cbsnews\.com/live/video/(?P<id>[^/?#]+)'
102 # Live videos get deleted soon. See http://www.cbsnews.com/live/ for the latest examples
104 'url': 'http://www.cbsnews.com/live/video/clinton-sanders-prepare-to-face-off-in-nh/',
106 'id': 'clinton-sanders-prepare-to-face-off-in-nh',
108 'title': 'Clinton, Sanders Prepare To Face Off In NH',
111 'skip': 'Video gone',
114 def _real_extract(self, url):
115 display_id = self._match_id(url)
117 video_info = self._download_json(
118 'http://feeds.cbsn.cbsnews.com/rundown/story', display_id, query={
120 'dvr_slug': display_id,
123 formats = self._extract_akamai_formats(video_info['url'], display_id)
124 self._sort_formats(formats)
128 'display_id': display_id,
129 'title': video_info['headline'],
130 'thumbnail': video_info.get('thumbnail_url_hd') or video_info.get('thumbnail_url_sd'),
131 'duration': parse_duration(video_info.get('segmentDur')),