[cleanup] Make more playlist entries lazy (#11763)
[yt-dlp.git] / yt_dlp / extractor / tvanouvelles.py
blob855c771ec53548565d49eca717bffb9aa6962bd1
1 import re
3 from .brightcove import BrightcoveNewIE
4 from .common import InfoExtractor
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',
20 'add_ie': ['BrightcoveNew'],
22 BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1741764581/default_default/index.html?videoId=%s'
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)
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',
40 'playlist_mincount': 4,
43 @classmethod
44 def suitable(cls, url):
45 return False if TVANouvellesIE.suitable(url) else super().suitable(url)
47 def _real_extract(self, url):
48 display_id = self._match_id(url)
50 webpage = self._download_webpage(url, display_id)
52 entries = [
53 self.url_result(
54 'http://www.tvanouvelles.ca/videos/{}'.format(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)]
59 title = self._og_search_title(webpage, fatal=False)
60 description = self._og_search_description(webpage)
62 return self.playlist_result(entries, display_id, title, description)