]>
Commit | Line | Data |
---|---|---|
c131fc33 S |
1 | import re |
2 | ||
3 | from .common import InfoExtractor | |
4 | from .brightcove import BrightcoveNewIE | |
5 | ||
6 | ||
7 | class TVANouvellesIE(InfoExtractor): | |
8 | _VALID_URL = r'https?://(?:www\.)?tvanouvelles\.ca/videos/(?P<id>\d+)' | |
9 | _TEST = { | |
10 | 'url': 'http://www.tvanouvelles.ca/videos/5117035533001', | |
11 | 'info_dict': { | |
12 | 'id': '5117035533001', | |
13 | 'ext': 'mp4', | |
14 | 'title': 'L’industrie du taxi dénonce l’entente entre Québec et Uber: explications', | |
15 | 'description': 'md5:479653b7c8cf115747bf5118066bd8b3', | |
16 | 'uploader_id': '1741764581', | |
17 | 'timestamp': 1473352030, | |
18 | 'upload_date': '20160908', | |
19 | }, | |
20 | 'add_ie': ['BrightcoveNew'], | |
21 | } | |
22 | BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1741764581/default_default/index.html?videoId=%s' | |
23 | ||
24 | def _real_extract(self, url): | |
25 | brightcove_id = self._match_id(url) | |
26 | return self.url_result( | |
27 | self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id, | |
28 | BrightcoveNewIE.ie_key(), brightcove_id) | |
29 | ||
30 | ||
31 | class TVANouvellesArticleIE(InfoExtractor): | |
32 | _VALID_URL = r'https?://(?:www\.)?tvanouvelles\.ca/(?:[^/]+/)+(?P<id>[^/?#&]+)' | |
33 | _TEST = { | |
34 | 'url': 'http://www.tvanouvelles.ca/2016/11/17/des-policiers-qui-ont-la-meche-un-peu-courte', | |
35 | 'info_dict': { | |
36 | 'id': 'des-policiers-qui-ont-la-meche-un-peu-courte', | |
37 | 'title': 'Des policiers qui ont «la mèche un peu courte»?', | |
38 | 'description': 'md5:92d363c8eb0f0f030de9a4a84a90a3a0', | |
39 | }, | |
40 | 'playlist_mincount': 4, | |
41 | } | |
42 | ||
43 | @classmethod | |
44 | def suitable(cls, url): | |
45 | return False if TVANouvellesIE.suitable(url) else super(TVANouvellesArticleIE, cls).suitable(url) | |
46 | ||
47 | def _real_extract(self, url): | |
48 | display_id = self._match_id(url) | |
49 | ||
50 | webpage = self._download_webpage(url, display_id) | |
51 | ||
52 | entries = [ | |
53 | self.url_result( | |
54 | 'http://www.tvanouvelles.ca/videos/%s' % mobj.group('id'), | |
55 | ie=TVANouvellesIE.ie_key(), video_id=mobj.group('id')) | |
56 | for mobj in re.finditer( | |
57 | r'data-video-id=(["\'])?(?P<id>\d+)', webpage)] | |
58 | ||
59 | title = self._og_search_title(webpage, fatal=False) | |
60 | description = self._og_search_description(webpage) | |
61 | ||
62 | return self.playlist_result(entries, display_id, title, description) |