]>
Commit | Line | Data |
---|---|---|
dcdb292f | 1 | # coding: utf-8 |
85e787f5 S |
2 | from __future__ import unicode_literals |
3 | ||
2e11e51c RA |
4 | import re |
5 | import zlib | |
6 | ||
fd3a1f3d | 7 | from .common import InfoExtractor |
dabe1570 | 8 | from .cbs import CBSIE |
2e11e51c RA |
9 | from ..compat import ( |
10 | compat_b64decode, | |
11 | compat_urllib_parse_unquote, | |
12 | ) | |
8b809a07 | 13 | from ..utils import ( |
14 | parse_duration, | |
8b809a07 | 15 | ) |
85e787f5 S |
16 | |
17 | ||
2e11e51c RA |
18 | class CBSNewsEmbedIE(CBSIE): |
19 | IE_NAME = 'cbsnews:embed' | |
20 | _VALID_URL = r'https?://(?:www\.)?cbsnews\.com/embed/video[^#]*#(?P<id>.+)' | |
21 | _TESTS = [{ | |
22 | 'url': 'https://www.cbsnews.com/embed/video/?v=1.c9b5b61492913d6660db0b2f03579ef25e86307a#1Vb7b9s2EP5XBAHbT6Gt98PAMKTJ0se6LVjWYWtdGBR1stlIpEBSTtwi%2F%2FvuJNkNhmHdGxgM2NL57vjd6zt%2B8PngdN%2Fyg79qeGvhzN%2FLGrS%2F%2BuBLB531V28%2B%2BO7Qg7%2Fy97r2z3xZ42NW8yLhDbA0S0KWlHnIijwKWJBHZZnHBa8Cgbpdf%2F89NM9Hi9fXifhpr8sr%2FlP848tn%2BTdXycX25zh4cdX%2FvHl6PmmPqnWQv9w8Ed%2B9GjYRim07bFEqdG%2BZVHuwTm65A7bVRrYtR5lAyMox7pigF6W4k%2By91mjspGsJ%2BwVae4%2BsvdnaO1p73HkXs%2FVisUDTGm7R8IcdnOROeq%2B19qT1amhA1VJtPenoTUgrtfKc9m7Rq8dP7nnjwOB7wg7ADdNt7VX64DWAWlKhPtmDEq22g4GF99x6Dk9E8OSsankHXqPNKDxC%2FdK7MLKTircTDgsI3mmj4OBdSq64dy7fd1x577RU1rt4cvMtOaulFYOd%2FLewRWvDO9lIgXFpZSnkZmjbv5SxKTPoQXClF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hXEH9WOG2%2FkOE833sfeG%2Ff5cfHtEFNXgYes0%2FXj7aGivUgJ9XpusCtoNcNYVVnJVrrDo0OmJAutHCpuZul4W9lLcfy7BnuLPT02%2ByXsCTk%2B9zhzswIN04YueNSK%2BPtM0jS88QdLqSLJDTLsuGZJNolm2yO0PXh3UPnz9Ix5bfIAqxPjvETQsDCEiPG4QbqNyhBZISxybLnZYCrW5H3Axp690%2F0BJdXtDZ5ITuM4xj3f4oUHGzc5JeJmZKpp%2FjwKh4wMV%2FV1yx3emLoR0MwbG4K%2F%2BZgVep3PnzXGDHZ6a3i%2Fk%2BJrONDN13%2Bnq6tBTYk4o7cLGhBtqCC4KwacGHpEVuoH5JNro%2FE6JfE6d5RydbiR76k%2BW5wioDHBIjw1euhHjUGRB0y5A97KoaPx6MlL%2BwgboUVtUFRI%2FLemgTpdtF59ii7pab08kuPcfWzs0l%2FRI5takWnFpka0zOgWRtYcuf9aIxZMxlwr6IiGpsb6j2DQUXPl%2FimXI599Ev7fWjoPD78A', | |
23 | 'only_matching': True, | |
24 | }] | |
25 | ||
26 | def _real_extract(self, url): | |
27 | item = self._parse_json(zlib.decompress(compat_b64decode( | |
28 | compat_urllib_parse_unquote(self._match_id(url))), | |
201c1459 | 29 | -zlib.MAX_WBITS).decode('utf-8'), None)['video']['items'][0] |
2e11e51c RA |
30 | return self._extract_video_info(item['mpxRefId'], 'cbsnews') |
31 | ||
32 | ||
dabe1570 | 33 | class CBSNewsIE(CBSIE): |
7fd57de6 | 34 | IE_NAME = 'cbsnews' |
85e787f5 | 35 | IE_DESC = 'CBS News' |
2e11e51c | 36 | _VALID_URL = r'https?://(?:www\.)?cbsnews\.com/(?:news|video)/(?P<id>[\da-z_-]+)' |
85e787f5 S |
37 | |
38 | _TESTS = [ | |
39 | { | |
a919ca0a S |
40 | # 60 minutes |
41 | 'url': 'http://www.cbsnews.com/news/artificial-intelligence-positioned-to-be-a-game-changer/', | |
85e787f5 | 42 | 'info_dict': { |
2e11e51c RA |
43 | 'id': 'Y_nf_aEg6WwO9OLAq0MpKaPgfnBUxfW4', |
44 | 'ext': 'flv', | |
45 | 'title': 'Artificial Intelligence, real-life applications', | |
46 | 'description': 'md5:a7aaf27f1b4777244de8b0b442289304', | |
a919ca0a | 47 | 'thumbnail': r're:^https?://.*\.jpg$', |
2e11e51c | 48 | 'duration': 317, |
a919ca0a | 49 | 'uploader': 'CBSI-NEW', |
2e11e51c RA |
50 | 'timestamp': 1476046464, |
51 | 'upload_date': '20161009', | |
85e787f5 S |
52 | }, |
53 | 'params': { | |
2e11e51c | 54 | # rtmp download |
85e787f5 S |
55 | 'skip_download': True, |
56 | }, | |
57 | }, | |
58 | { | |
2e11e51c | 59 | 'url': 'https://www.cbsnews.com/video/fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack/', |
85e787f5 | 60 | 'info_dict': { |
43518503 | 61 | 'id': 'SNJBOYzXiWBOvaLsdzwH8fmtP1SCd91Y', |
f125d911 | 62 | 'ext': 'mp4', |
85e787f5 | 63 | 'title': 'Fort Hood shooting: Army downplays mental illness as cause of attack', |
43518503 | 64 | 'description': 'md5:4a6983e480542d8b333a947bfc64ddc7', |
dabe1570 RA |
65 | 'upload_date': '20140404', |
66 | 'timestamp': 1396650660, | |
43518503 | 67 | 'uploader': 'CBSI-NEW', |
ec85ded8 | 68 | 'thumbnail': r're:^https?://.*\.jpg$', |
85e787f5 | 69 | 'duration': 205, |
220ee33f S |
70 | 'subtitles': { |
71 | 'en': [{ | |
72 | 'ext': 'ttml', | |
73 | }], | |
74 | }, | |
4118cc02 JA |
75 | }, |
76 | 'params': { | |
f125d911 | 77 | # m3u8 download |
4118cc02 JA |
78 | 'skip_download': True, |
79 | }, | |
80 | }, | |
88d6b7c2 | 81 | { |
a919ca0a | 82 | # 48 hours |
88d6b7c2 PV |
83 | 'url': 'http://www.cbsnews.com/news/maria-ridulph-murder-will-the-nations-oldest-cold-case-to-go-to-trial-ever-get-solved/', |
84 | 'info_dict': { | |
88d6b7c2 | 85 | 'title': 'Cold as Ice', |
2e11e51c | 86 | 'description': 'Can a childhood memory solve the 1957 murder of 7-year-old Maria Ridulph?', |
88d6b7c2 | 87 | }, |
2e11e51c | 88 | 'playlist_mincount': 7, |
88d6b7c2 | 89 | }, |
85e787f5 S |
90 | ] |
91 | ||
92 | def _real_extract(self, url): | |
2e11e51c | 93 | display_id = self._match_id(url) |
85e787f5 | 94 | |
2e11e51c | 95 | webpage = self._download_webpage(url, display_id) |
85e787f5 | 96 | |
2e11e51c RA |
97 | entries = [] |
98 | for embed_url in re.findall(r'<iframe[^>]+data-src="(https?://(?:www\.)?cbsnews\.com/embed/video/[^#]*#[^"]+)"', webpage): | |
99 | entries.append(self.url_result(embed_url, CBSNewsEmbedIE.ie_key())) | |
100 | if entries: | |
101 | return self.playlist_result( | |
102 | entries, playlist_title=self._html_search_meta(['og:title', 'twitter:title'], webpage), | |
103 | playlist_description=self._html_search_meta(['og:description', 'twitter:description', 'description'], webpage)) | |
7f4c3a74 | 104 | |
2e11e51c RA |
105 | item = self._parse_json(self._html_search_regex( |
106 | r'CBSNEWS\.defaultPayload\s*=\s*({.+})', | |
107 | webpage, 'video JSON info'), display_id)['items'][0] | |
7f4c3a74 | 108 | return self._extract_video_info(item['mpxRefId'], 'cbsnews') |
fd3a1f3d | 109 | |
110 | ||
111 | class CBSNewsLiveVideoIE(InfoExtractor): | |
7fd57de6 | 112 | IE_NAME = 'cbsnews:livevideo' |
fd3a1f3d | 113 | IE_DESC = 'CBS News Live Videos' |
7fd57de6 | 114 | _VALID_URL = r'https?://(?:www\.)?cbsnews\.com/live/video/(?P<id>[^/?#]+)' |
fd3a1f3d | 115 | |
69eb4d69 YCH |
116 | # Live videos get deleted soon. See http://www.cbsnews.com/live/ for the latest examples |
117 | _TEST = { | |
fd3a1f3d | 118 | 'url': 'http://www.cbsnews.com/live/video/clinton-sanders-prepare-to-face-off-in-nh/', |
119 | 'info_dict': { | |
120 | 'id': 'clinton-sanders-prepare-to-face-off-in-nh', | |
7fd57de6 | 121 | 'ext': 'mp4', |
fd3a1f3d | 122 | 'title': 'Clinton, Sanders Prepare To Face Off In NH', |
123 | 'duration': 334, | |
124 | }, | |
69eb4d69 YCH |
125 | 'skip': 'Video gone', |
126 | } | |
fd3a1f3d | 127 | |
128 | def _real_extract(self, url): | |
7fd57de6 | 129 | display_id = self._match_id(url) |
fd3a1f3d | 130 | |
7fd57de6 RA |
131 | video_info = self._download_json( |
132 | 'http://feeds.cbsn.cbsnews.com/rundown/story', display_id, query={ | |
133 | 'device': 'desktop', | |
134 | 'dvr_slug': display_id, | |
135 | }) | |
fd3a1f3d | 136 | |
7fd57de6 RA |
137 | formats = self._extract_akamai_formats(video_info['url'], display_id) |
138 | self._sort_formats(formats) | |
fd3a1f3d | 139 | |
140 | return { | |
7fd57de6 RA |
141 | 'id': display_id, |
142 | 'display_id': display_id, | |
fd3a1f3d | 143 | 'title': video_info['headline'], |
144 | 'thumbnail': video_info.get('thumbnail_url_hd') or video_info.get('thumbnail_url_sd'), | |
145 | 'duration': parse_duration(video_info.get('segmentDur')), | |
7fd57de6 | 146 | 'formats': formats, |
fd3a1f3d | 147 | } |