]>
Commit | Line | Data |
---|---|---|
bf4fa244 RA |
1 | import re |
2 | ||
3 | from .common import InfoExtractor | |
c9e538a3 | 4 | from ..utils import orderedSet |
bf4fa244 RA |
5 | |
6 | ||
7 | class CTVNewsIE(InfoExtractor): | |
f0b69fa9 | 8 | _VALID_URL = r'https?://(?:.+?\.)?ctvnews\.ca/(?:video\?(?:clip|playlist|bin)Id=|.*?)(?P<id>[0-9.]+)' |
bf4fa244 RA |
9 | _TESTS = [{ |
10 | 'url': 'http://www.ctvnews.ca/video?clipId=901995', | |
c9e12a61 | 11 | 'md5': '9b8624ba66351a23e0b6e1391971f9af', |
bf4fa244 RA |
12 | 'info_dict': { |
13 | 'id': '901995', | |
c9e12a61 | 14 | 'ext': 'flv', |
bf4fa244 RA |
15 | 'title': 'Extended: \'That person cannot be me\' Johnson says', |
16 | 'description': 'md5:958dd3b4f5bbbf0ed4d045c790d89285', | |
17 | 'timestamp': 1467286284, | |
18 | 'upload_date': '20160630', | |
19 | } | |
20 | }, { | |
21 | 'url': 'http://www.ctvnews.ca/video?playlistId=1.2966224', | |
22 | 'info_dict': | |
23 | { | |
24 | 'id': '1.2966224', | |
25 | }, | |
26 | 'playlist_mincount': 19, | |
27 | }, { | |
c9e538a3 | 28 | 'url': 'http://www.ctvnews.ca/video?binId=1.2876780', |
bf4fa244 RA |
29 | 'info_dict': |
30 | { | |
c9e538a3 | 31 | 'id': '1.2876780', |
bf4fa244 | 32 | }, |
c9e538a3 | 33 | 'playlist_mincount': 100, |
bf4fa244 RA |
34 | }, { |
35 | 'url': 'http://www.ctvnews.ca/1.810401', | |
36 | 'only_matching': True, | |
37 | }, { | |
38 | 'url': 'http://www.ctvnews.ca/canadiens-send-p-k-subban-to-nashville-in-blockbuster-trade-1.2967231', | |
39 | 'only_matching': True, | |
f0b69fa9 RA |
40 | }, { |
41 | 'url': 'http://vancouverisland.ctvnews.ca/video?clipId=761241', | |
42 | 'only_matching': True, | |
bf4fa244 RA |
43 | }] |
44 | ||
45 | def _real_extract(self, url): | |
46 | page_id = self._match_id(url) | |
47 | ||
48 | def ninecninemedia_url_result(clip_id): | |
49 | return { | |
50 | '_type': 'url_transparent', | |
51 | 'id': clip_id, | |
52 | 'url': '9c9media:ctvnews_web:%s' % clip_id, | |
53 | 'ie_key': 'NineCNineMedia', | |
54 | } | |
55 | ||
56 | if page_id.isdigit(): | |
57 | return ninecninemedia_url_result(page_id) | |
58 | else: | |
59 | webpage = self._download_webpage('http://www.ctvnews.ca/%s' % page_id, page_id, query={ | |
60 | 'ot': 'example.AjaxPageLayout.ot', | |
c9e538a3 | 61 | 'maxItemsPerPage': 1000000, |
bf4fa244 | 62 | }) |
c9e538a3 | 63 | entries = [ninecninemedia_url_result(clip_id) for clip_id in orderedSet( |
bf4fa244 | 64 | re.findall(r'clip\.id\s*=\s*(\d+);', webpage))] |
dfb7f2a2 AG |
65 | if not entries: |
66 | webpage = self._download_webpage(url, page_id) | |
67 | if 'getAuthStates("' in webpage: | |
68 | entries = [ninecninemedia_url_result(clip_id) for clip_id in | |
69 | self._search_regex(r'getAuthStates\("([\d+,]+)"', webpage, 'clip ids').split(',')] | |
bf4fa244 | 70 | return self.playlist_result(entries, page_id) |