]>
Commit | Line | Data |
---|---|---|
dcdb292f | 1 | # coding: utf-8 |
85e787f5 S |
2 | from __future__ import unicode_literals |
3 | ||
fd3a1f3d | 4 | from .common import InfoExtractor |
dabe1570 | 5 | from .cbs import CBSIE |
8b809a07 | 6 | from ..utils import ( |
7 | parse_duration, | |
8b809a07 | 8 | ) |
85e787f5 S |
9 | |
10 | ||
dabe1570 | 11 | class CBSNewsIE(CBSIE): |
7fd57de6 | 12 | IE_NAME = 'cbsnews' |
85e787f5 | 13 | IE_DESC = 'CBS News' |
5886b38d | 14 | _VALID_URL = r'https?://(?:www\.)?cbsnews\.com/(?:news|videos)/(?P<id>[\da-z_-]+)' |
85e787f5 S |
15 | |
16 | _TESTS = [ | |
17 | { | |
a919ca0a S |
18 | # 60 minutes |
19 | 'url': 'http://www.cbsnews.com/news/artificial-intelligence-positioned-to-be-a-game-changer/', | |
85e787f5 | 20 | 'info_dict': { |
a919ca0a S |
21 | 'id': '_B6Ga3VJrI4iQNKsir_cdFo9Re_YJHE_', |
22 | 'ext': 'mp4', | |
23 | 'title': 'Artificial Intelligence', | |
24 | 'description': 'md5:8818145f9974431e0fb58a1b8d69613c', | |
25 | 'thumbnail': r're:^https?://.*\.jpg$', | |
26 | 'duration': 1606, | |
27 | 'uploader': 'CBSI-NEW', | |
28 | 'timestamp': 1498431900, | |
29 | 'upload_date': '20170625', | |
85e787f5 S |
30 | }, |
31 | 'params': { | |
a919ca0a | 32 | # m3u8 download |
85e787f5 S |
33 | 'skip_download': True, |
34 | }, | |
35 | }, | |
36 | { | |
37 | 'url': 'http://www.cbsnews.com/videos/fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack/', | |
38 | 'info_dict': { | |
43518503 | 39 | 'id': 'SNJBOYzXiWBOvaLsdzwH8fmtP1SCd91Y', |
f125d911 | 40 | 'ext': 'mp4', |
85e787f5 | 41 | 'title': 'Fort Hood shooting: Army downplays mental illness as cause of attack', |
43518503 | 42 | 'description': 'md5:4a6983e480542d8b333a947bfc64ddc7', |
dabe1570 RA |
43 | 'upload_date': '20140404', |
44 | 'timestamp': 1396650660, | |
43518503 | 45 | 'uploader': 'CBSI-NEW', |
ec85ded8 | 46 | 'thumbnail': r're:^https?://.*\.jpg$', |
85e787f5 | 47 | 'duration': 205, |
220ee33f S |
48 | 'subtitles': { |
49 | 'en': [{ | |
50 | 'ext': 'ttml', | |
51 | }], | |
52 | }, | |
4118cc02 JA |
53 | }, |
54 | 'params': { | |
f125d911 | 55 | # m3u8 download |
4118cc02 JA |
56 | 'skip_download': True, |
57 | }, | |
58 | }, | |
88d6b7c2 | 59 | { |
a919ca0a | 60 | # 48 hours |
88d6b7c2 PV |
61 | 'url': 'http://www.cbsnews.com/news/maria-ridulph-murder-will-the-nations-oldest-cold-case-to-go-to-trial-ever-get-solved/', |
62 | 'info_dict': { | |
63 | 'id': 'QpM5BJjBVEAUFi7ydR9LusS69DPLqPJ1', | |
64 | 'ext': 'mp4', | |
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', | |
70 | }, | |
71 | 'params': { | |
72 | 'skip_download': True, | |
73 | }, | |
74 | }, | |
85e787f5 S |
75 | ] |
76 | ||
77 | def _real_extract(self, url): | |
fd3a1f3d | 78 | video_id = self._match_id(url) |
85e787f5 S |
79 | |
80 | webpage = self._download_webpage(url, video_id) | |
81 | ||
fd3a1f3d | 82 | video_info = self._parse_json(self._html_search_regex( |
88d6b7c2 | 83 | r'(?:<ul class="media-list items" id="media-related-items"[^>]*><li data-video-info|<div id="cbsNewsVideoPlayer" data-video-player-options)=\'({.+?})\'', |
7f4c3a74 | 84 | webpage, 'video JSON info', default='{}'), video_id, fatal=False) |
85e787f5 | 85 | |
7f4c3a74 S |
86 | if video_info: |
87 | item = video_info['item'] if 'item' in video_info else video_info | |
88 | else: | |
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']] | |
93 | ||
94 | return self._extract_video_info(item['mpxRefId'], 'cbsnews') | |
fd3a1f3d | 95 | |
96 | ||
97 | class CBSNewsLiveVideoIE(InfoExtractor): | |
7fd57de6 | 98 | IE_NAME = 'cbsnews:livevideo' |
fd3a1f3d | 99 | IE_DESC = 'CBS News Live Videos' |
7fd57de6 | 100 | _VALID_URL = r'https?://(?:www\.)?cbsnews\.com/live/video/(?P<id>[^/?#]+)' |
fd3a1f3d | 101 | |
69eb4d69 YCH |
102 | # Live videos get deleted soon. See http://www.cbsnews.com/live/ for the latest examples |
103 | _TEST = { | |
fd3a1f3d | 104 | 'url': 'http://www.cbsnews.com/live/video/clinton-sanders-prepare-to-face-off-in-nh/', |
105 | 'info_dict': { | |
106 | 'id': 'clinton-sanders-prepare-to-face-off-in-nh', | |
7fd57de6 | 107 | 'ext': 'mp4', |
fd3a1f3d | 108 | 'title': 'Clinton, Sanders Prepare To Face Off In NH', |
109 | 'duration': 334, | |
110 | }, | |
69eb4d69 YCH |
111 | 'skip': 'Video gone', |
112 | } | |
fd3a1f3d | 113 | |
114 | def _real_extract(self, url): | |
7fd57de6 | 115 | display_id = self._match_id(url) |
fd3a1f3d | 116 | |
7fd57de6 RA |
117 | video_info = self._download_json( |
118 | 'http://feeds.cbsn.cbsnews.com/rundown/story', display_id, query={ | |
119 | 'device': 'desktop', | |
120 | 'dvr_slug': display_id, | |
121 | }) | |
fd3a1f3d | 122 | |
7fd57de6 RA |
123 | formats = self._extract_akamai_formats(video_info['url'], display_id) |
124 | self._sort_formats(formats) | |
fd3a1f3d | 125 | |
126 | return { | |
7fd57de6 RA |
127 | 'id': display_id, |
128 | 'display_id': display_id, | |
fd3a1f3d | 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')), | |
7fd57de6 | 132 | 'formats': formats, |
fd3a1f3d | 133 | } |