2 from __future__ import unicode_literals
7 from .common import InfoExtractor
10 class VierIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?vier\.be/(?:[^/]+/videos/(?P<display_id>[^/]+)(?:/(?P<id>\d+))?|video/v3/embed/(?P<embed_id>\d+))'
14 'url': 'http://www.vier.be/planb/videos/het-wordt-warm-de-moestuin/16129',
17 'display_id': 'het-wordt-warm-de-moestuin',
19 'title': 'Het wordt warm in De Moestuin',
20 'description': 'De vele uren werk eisen hun tol. Wim droomt van assistentie...',
24 'skip_download': True,
27 'url': 'http://www.vier.be/planb/videos/mieren-herders-van-de-bladluizen',
28 'only_matching': True,
30 'url': 'http://www.vier.be/video/v3/embed/16129',
31 'only_matching': True,
34 def _real_extract(self, url):
35 mobj = re.match(self._VALID_URL, url)
36 embed_id = mobj.group('embed_id')
37 display_id = mobj.group('display_id') or embed_id
39 webpage = self._download_webpage(url, display_id)
41 video_id = self._search_regex(
42 [r'data-nid="(\d+)"', r'"nid"\s*:\s*"(\d+)"'],
44 application = self._search_regex(
45 [r'data-application="([^"]+)"', r'"application"\s*:\s*"([^"]+)"'],
46 webpage, 'application', default='vier_vod')
47 filename = self._search_regex(
48 [r'data-filename="([^"]+)"', r'"filename"\s*:\s*"([^"]+)"'],
51 playlist_url = 'http://vod.streamcloud.be/%s/mp4:_definst_/%s.mp4/playlist.m3u8' % (application, filename)
52 formats = self._extract_m3u8_formats(playlist_url, display_id, 'mp4')
54 title = self._og_search_title(webpage, default=display_id)
55 description = self._og_search_description(webpage, default=None)
56 thumbnail = self._og_search_thumbnail(webpage, default=None)
60 'display_id': display_id,
62 'description': description,
63 'thumbnail': thumbnail,
68 class VierVideosIE(InfoExtractor):
69 IE_NAME = 'vier:videos'
70 _VALID_URL = r'https?://(?:www\.)?vier\.be/(?P<program>[^/]+)/videos(?:\?.*\bpage=(?P<page>\d+)|$)'
72 'url': 'http://www.vier.be/demoestuin/videos',
76 'playlist_mincount': 153,
78 'url': 'http://www.vier.be/demoestuin/videos?page=6',
80 'id': 'demoestuin-page6',
82 'playlist_mincount': 20,
84 'url': 'http://www.vier.be/demoestuin/videos?page=7',
86 'id': 'demoestuin-page7',
88 'playlist_mincount': 13,
91 def _real_extract(self, url):
92 mobj = re.match(self._VALID_URL, url)
93 program = mobj.group('program')
95 page_id = mobj.group('page')
97 page_id = int(page_id)
99 playlist_id = '%s-page%d' % (program, page_id)
102 playlist_id = program
105 for current_page_id in itertools.count(start_page):
106 current_page = self._download_webpage(
107 'http://www.vier.be/%s/videos?page=%d' % (program, current_page_id),
109 'Downloading page %d' % (current_page_id + 1))
111 self.url_result('http://www.vier.be' + video_url, 'Vier')
112 for video_url in re.findall(
113 r'<h3><a href="(/[^/]+/videos/[^/]+(?:/\d+)?)">', current_page)]
114 entries.extend(page_entries)
115 if page_id or '>Meer<' not in current_page:
118 return self.playlist_result(entries, playlist_id)