]>
Commit | Line | Data |
---|---|---|
661d46b2 YCH |
1 | from .anvato import AnvatoIE |
2 | from .sendtonews import SendtoNewsIE | |
3 | from ..compat import compat_urlparse | |
44444f0d YCH |
4 | from ..utils import ( |
5 | parse_iso8601, | |
6 | unified_timestamp, | |
7 | ) | |
661d46b2 YCH |
8 | |
9 | ||
6368e2e6 | 10 | class CBSLocalIE(AnvatoIE): # XXX: Do not subclass from concrete IE |
29f7c58a | 11 | _VALID_URL_BASE = r'https?://[a-z]+\.cbslocal\.com/' |
12 | _VALID_URL = _VALID_URL_BASE + r'video/(?P<id>\d+)' | |
13 | ||
14 | _TESTS = [{ | |
15 | 'url': 'http://newyork.cbslocal.com/video/3580809-a-very-blue-anniversary/', | |
16 | 'info_dict': { | |
17 | 'id': '3580809', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'A Very Blue Anniversary', | |
20 | 'description': 'CBS2’s Cindy Hsu has more.', | |
21 | 'thumbnail': 're:^https?://.*', | |
22 | 'timestamp': int, | |
23 | 'upload_date': r're:^\d{8}$', | |
24 | 'uploader': 'CBS', | |
25 | 'subtitles': { | |
26 | 'en': 'mincount:5', | |
27 | }, | |
28 | 'categories': [ | |
29 | 'Stations\\Spoken Word\\WCBSTV', | |
30 | 'Syndication\\AOL', | |
31 | 'Syndication\\MSN', | |
32 | 'Syndication\\NDN', | |
33 | 'Syndication\\Yahoo', | |
34 | 'Content\\News', | |
35 | 'Content\\News\\Local News', | |
36 | ], | |
37 | 'tags': ['CBS 2 News Weekends', 'Cindy Hsu', 'Blue Man Group'], | |
38 | }, | |
39 | 'params': { | |
40 | 'skip_download': True, | |
41 | }, | |
42 | }] | |
43 | ||
44 | def _real_extract(self, url): | |
45 | mcp_id = self._match_id(url) | |
46 | return self.url_result( | |
47 | 'anvato:anvato_cbslocal_app_web_prod_547f3e49241ef0e5d30c79b2efbca5d92c698f67:' + mcp_id, 'Anvato', mcp_id) | |
48 | ||
49 | ||
6368e2e6 | 50 | class CBSLocalArticleIE(AnvatoIE): # XXX: Do not subclass from concrete IE |
29f7c58a | 51 | _VALID_URL = CBSLocalIE._VALID_URL_BASE + r'\d+/\d+/\d+/(?P<id>[0-9a-z-]+)' |
661d46b2 YCH |
52 | |
53 | _TESTS = [{ | |
54 | # Anvato backend | |
55 | 'url': 'http://losangeles.cbslocal.com/2016/05/16/safety-advocates-say-fatal-car-seat-failures-are-public-health-crisis', | |
56 | 'md5': 'f0ee3081e3843f575fccef901199b212', | |
57 | 'info_dict': { | |
58 | 'id': '3401037', | |
59 | 'ext': 'mp4', | |
60 | 'title': 'Safety Advocates Say Fatal Car Seat Failures Are \'Public Health Crisis\'', | |
61 | 'description': 'Collapsing seats have been the focus of scrutiny for decades, though experts say remarkably little has been done to address the issue. Randy Paige reports.', | |
62 | 'thumbnail': 're:^https?://.*', | |
63 | 'timestamp': 1463440500, | |
64 | 'upload_date': '20160516', | |
c897af8a | 65 | 'uploader': 'CBS', |
661d46b2 YCH |
66 | 'subtitles': { |
67 | 'en': 'mincount:5', | |
68 | }, | |
69 | 'categories': [ | |
70 | 'Stations\\Spoken Word\\KCBSTV', | |
71 | 'Syndication\\MSN', | |
72 | 'Syndication\\NDN', | |
73 | 'Syndication\\AOL', | |
74 | 'Syndication\\Yahoo', | |
75 | 'Syndication\\Tribune', | |
76 | 'Syndication\\Curb.tv', | |
77 | 'Content\\News' | |
78 | ], | |
c897af8a | 79 | 'tags': ['CBS 2 News Evening'], |
661d46b2 YCH |
80 | }, |
81 | }, { | |
82 | # SendtoNews embed | |
83 | 'url': 'http://cleveland.cbslocal.com/2016/05/16/indians-score-season-high-15-runs-in-blowout-win-over-reds-rapid-reaction/', | |
84 | 'info_dict': { | |
85 | 'id': 'GxfCe0Zo7D-175909-5588', | |
661d46b2 | 86 | }, |
760845ce | 87 | 'playlist_count': 9, |
661d46b2 YCH |
88 | 'params': { |
89 | # m3u8 download | |
90 | 'skip_download': True, | |
91 | }, | |
92 | }] | |
93 | ||
94 | def _real_extract(self, url): | |
95 | display_id = self._match_id(url) | |
96 | webpage = self._download_webpage(url, display_id) | |
97 | ||
98 | sendtonews_url = SendtoNewsIE._extract_url(webpage) | |
99 | if sendtonews_url: | |
760845ce YCH |
100 | return self.url_result( |
101 | compat_urlparse.urljoin(url, sendtonews_url), | |
102 | ie=SendtoNewsIE.ie_key()) | |
103 | ||
104 | info_dict = self._extract_anvato_videos(webpage, display_id) | |
661d46b2 | 105 | |
06dbcd7b S |
106 | timestamp = unified_timestamp(self._html_search_regex( |
107 | r'class="(?:entry|post)-date"[^>]*>([^<]+)', webpage, | |
108 | 'released date', default=None)) or parse_iso8601( | |
109 | self._html_search_meta('uploadDate', webpage)) | |
661d46b2 YCH |
110 | |
111 | info_dict.update({ | |
112 | 'display_id': display_id, | |
113 | 'timestamp': timestamp, | |
114 | }) | |
115 | ||
116 | return info_dict |