2 from __future__ import unicode_literals
7 from .common import InfoExtractor
15 class VierIE(InfoExtractor):
17 IE_DESC = 'vier.be and vijf.be'
20 (?:www\.)?(?P<site>vier|vijf)\.be/
26 (?P<display_id>[^/]+)(?:/(?P<id>\d+))?|
33 _NETRC_MACHINE = 'vier'
35 'url': 'http://www.vier.be/planb/videos/het-wordt-warm-de-moestuin/16129',
36 'md5': 'e4ae2054a6b040ef1e289e20d111b46e',
39 'display_id': 'het-wordt-warm-de-moestuin',
41 'title': 'Het wordt warm in De Moestuin',
42 'description': 'De vele uren werk eisen hun tol. Wim droomt van assistentie...',
43 'upload_date': '20121025',
45 'tags': ['De Moestuin', 'Moestuin', 'meisjes', 'Tomaat', 'Wim', 'Droom'],
48 'url': 'http://www.vijf.be/temptationisland/videos/zo-grappig-temptation-island-hosts-moeten-kiezen-tussen-onmogelijke-dilemmas/2561614',
51 'display_id': 'zo-grappig-temptation-island-hosts-moeten-kiezen-tussen-onmogelijke-dilemmas',
53 'title': 'md5:84f45fe48b8c1fa296a7f6d208d080a7',
54 'description': 'md5:0356d4981e58b8cbee19355cbd51a8fe',
55 'upload_date': '20170228',
56 'series': 'Temptation Island',
60 'skip_download': True,
63 'url': 'http://www.vier.be/janigaat/videos/jani-gaat-naar-tokio-aflevering-4/2674839',
66 'display_id': 'jani-gaat-naar-tokio-aflevering-4',
68 'title': 'Jani gaat naar Tokio - Aflevering 4',
69 'description': 'md5:aa8d611541db6ae9e863125704511f88',
70 'upload_date': '20170501',
71 'series': 'Jani gaat',
73 'tags': ['Jani Gaat', 'Volledige Aflevering'],
76 'skip_download': True,
78 'skip': 'Requires account credentials',
80 # Requires account credentials but bypassed extraction via v3/embed page
82 'url': 'http://www.vier.be/janigaat/videos/jani-gaat-naar-tokio-aflevering-4/2674839',
85 'display_id': 'jani-gaat-naar-tokio-aflevering-4',
87 'title': 'jani-gaat-naar-tokio-aflevering-4',
90 'skip_download': True,
92 'expected_warnings': ['Log in to extract metadata'],
94 # Without video id in URL
95 'url': 'http://www.vier.be/planb/videos/dit-najaar-plan-b',
96 'only_matching': True,
98 'url': 'http://www.vier.be/video/v3/embed/16129',
99 'only_matching': True,
101 'url': 'https://www.vijf.be/embed/video/public/4093',
102 'only_matching': True,
104 'url': 'https://www.vier.be/video/blockbusters/in-juli-en-augustus-summer-classics',
105 'only_matching': True,
107 'url': 'https://www.vier.be/video/achter-de-rug/2017/achter-de-rug-seizoen-1-aflevering-6',
108 'only_matching': True,
111 def _real_initialize(self):
112 self._logged_in = False
114 def _login(self, site):
115 username, password = self._get_login_info()
116 if username is None or password is None:
119 login_page = self._download_webpage(
120 'http://www.%s.be/user/login' % site,
121 None, note='Logging in', errnote='Unable to log in',
122 data=urlencode_postdata({
123 'form_id': 'user_login',
127 headers={'Content-Type': 'application/x-www-form-urlencoded'})
129 login_error = self._html_search_regex(
130 r'(?s)<div class="messages error">\s*<div>\s*<h2.+?</h2>(.+?)<',
131 login_page, 'login error', default=None)
133 self.report_warning('Unable to log in: %s' % login_error)
135 self._logged_in = True
137 def _real_extract(self, url):
138 mobj = re.match(self._VALID_URL, url)
139 embed_id = mobj.group('embed_id')
140 display_id = mobj.group('display_id') or embed_id
141 video_id = mobj.group('id') or embed_id
142 site = mobj.group('site')
144 if not self._logged_in:
147 webpage = self._download_webpage(url, display_id)
149 if r'id="user-login"' in webpage:
151 'Log in to extract metadata', video_id=display_id)
152 webpage = self._download_webpage(
153 'http://www.%s.be/video/v3/embed/%s' % (site, video_id),
156 video_id = self._search_regex(
157 [r'data-nid="(\d+)"', r'"nid"\s*:\s*"(\d+)"'],
158 webpage, 'video id', default=video_id or display_id)
160 playlist_url = self._search_regex(
161 r'data-file=(["\'])(?P<url>(?:https?:)?//[^/]+/.+?\.m3u8.*?)\1',
162 webpage, 'm3u8 url', default=None, group='url')
165 application = self._search_regex(
166 [r'data-application="([^"]+)"', r'"application"\s*:\s*"([^"]+)"'],
167 webpage, 'application', default=site + '_vod')
168 filename = self._search_regex(
169 [r'data-filename="([^"]+)"', r'"filename"\s*:\s*"([^"]+)"'],
171 playlist_url = 'http://vod.streamcloud.be/%s/_definst_/mp4:%s.mp4/playlist.m3u8' % (application, filename)
173 formats = self._extract_wowza_formats(
174 playlist_url, display_id, skip_protocols=['dash'])
175 self._sort_formats(formats)
177 title = self._og_search_title(webpage, default=display_id)
178 description = self._html_search_regex(
179 r'(?s)<div\b[^>]+\bclass=(["\'])[^>]*?\bfield-type-text-with-summary\b[^>]*?\1[^>]*>.*?<p>(?P<value>.+?)</p>',
180 webpage, 'description', default=None, group='value')
181 thumbnail = self._og_search_thumbnail(webpage, default=None)
182 upload_date = unified_strdate(self._html_search_regex(
183 r'(?s)<div\b[^>]+\bclass=(["\'])[^>]*?\bfield-name-post-date\b[^>]*?\1[^>]*>.*?(?P<value>\d{2}/\d{2}/\d{4})',
184 webpage, 'upload date', default=None, group='value'))
186 series = self._search_regex(
187 r'data-program=(["\'])(?P<value>(?:(?!\1).)+)\1', webpage,
188 'series', default=None, group='value')
189 episode_number = int_or_none(self._search_regex(
190 r'(?i)aflevering (\d+)', title, 'episode number', default=None))
191 tags = re.findall(r'<a\b[^>]+\bhref=["\']/tags/[^>]+>([^<]+)<', webpage)
195 'display_id': display_id,
197 'description': description,
198 'thumbnail': thumbnail,
199 'upload_date': upload_date,
201 'episode_number': episode_number,
207 class VierVideosIE(InfoExtractor):
208 IE_NAME = 'vier:videos'
209 _VALID_URL = r'https?://(?:www\.)?(?P<site>vier|vijf)\.be/(?P<program>[^/]+)/videos(?:\?.*\bpage=(?P<page>\d+)|$)'
211 'url': 'http://www.vier.be/demoestuin/videos',
215 'playlist_mincount': 153,
217 'url': 'http://www.vijf.be/temptationisland/videos',
219 'id': 'temptationisland',
221 'playlist_mincount': 159,
223 'url': 'http://www.vier.be/demoestuin/videos?page=6',
225 'id': 'demoestuin-page6',
227 'playlist_mincount': 20,
229 'url': 'http://www.vier.be/demoestuin/videos?page=7',
231 'id': 'demoestuin-page7',
233 'playlist_mincount': 13,
236 def _real_extract(self, url):
237 mobj = re.match(self._VALID_URL, url)
238 program = mobj.group('program')
239 site = mobj.group('site')
241 page_id = mobj.group('page')
243 page_id = int(page_id)
245 playlist_id = '%s-page%d' % (program, page_id)
248 playlist_id = program
251 for current_page_id in itertools.count(start_page):
252 current_page = self._download_webpage(
253 'http://www.%s.be/%s/videos?page=%d' % (site, program, current_page_id),
255 'Downloading page %d' % (current_page_id + 1))
257 self.url_result('http://www.' + site + '.be' + video_url, 'Vier')
258 for video_url in re.findall(
259 r'<h[23]><a href="(/[^/]+/videos/[^/]+(?:/\d+)?)">', current_page)]
260 entries.extend(page_entries)
261 if page_id or '>Meer<' not in current_page:
264 return self.playlist_result(entries, playlist_id)