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