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