[cbslocal] Update test
[youtube-dl] / youtube_dl / extractor / cbslocal.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .anvato import AnvatoIE
5 from .sendtonews import SendtoNewsIE
6 from ..compat import compat_urlparse
7 from ..utils import unified_timestamp
8
9
10 class CBSLocalIE(AnvatoIE):
11     _VALID_URL = r'https?://[a-z]+\.cbslocal\.com/\d+/\d+/\d+/(?P<id>[0-9a-z-]+)'
12
13     _TESTS = [{
14         # Anvato backend
15         'url': 'http://losangeles.cbslocal.com/2016/05/16/safety-advocates-say-fatal-car-seat-failures-are-public-health-crisis',
16         'md5': 'f0ee3081e3843f575fccef901199b212',
17         'info_dict': {
18             'id': '3401037',
19             'ext': 'mp4',
20             'title': 'Safety Advocates Say Fatal Car Seat Failures Are \'Public Health Crisis\'',
21             '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.',
22             'thumbnail': 're:^https?://.*',
23             'timestamp': 1463440500,
24             'upload_date': '20160516',
25             'uploader': 'CBS',
26             'subtitles': {
27                 'en': 'mincount:5',
28             },
29             'categories': [
30                 'Stations\\Spoken Word\\KCBSTV',
31                 'Syndication\\MSN',
32                 'Syndication\\NDN',
33                 'Syndication\\AOL',
34                 'Syndication\\Yahoo',
35                 'Syndication\\Tribune',
36                 'Syndication\\Curb.tv',
37                 'Content\\News'
38             ],
39             'tags': ['CBS 2 News Evening'],
40         },
41     }, {
42         # SendtoNews embed
43         'url': 'http://cleveland.cbslocal.com/2016/05/16/indians-score-season-high-15-runs-in-blowout-win-over-reds-rapid-reaction/',
44         'info_dict': {
45             'id': 'GxfCe0Zo7D-175909-5588',
46         },
47         'playlist_count': 9,
48         'params': {
49             # m3u8 download
50             'skip_download': True,
51         },
52     }]
53
54     def _real_extract(self, url):
55         display_id = self._match_id(url)
56         webpage = self._download_webpage(url, display_id)
57
58         sendtonews_url = SendtoNewsIE._extract_url(webpage)
59         if sendtonews_url:
60             return self.url_result(
61                 compat_urlparse.urljoin(url, sendtonews_url),
62                 ie=SendtoNewsIE.ie_key())
63
64         info_dict = self._extract_anvato_videos(webpage, display_id)
65
66         time_str = self._html_search_regex(
67             r'class="entry-date">([^<]+)<', webpage, 'released date', fatal=False)
68         timestamp = unified_timestamp(time_str)
69
70         info_dict.update({
71             'display_id': display_id,
72             'timestamp': timestamp,
73         })
74
75         return info_dict