]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/zattoo.py
[extractor] Deprecate `_sort_formats`
[yt-dlp.git] / yt_dlp / extractor / zattoo.py
CommitLineData
4a733545 1import re
67ca1a8e 2from uuid import uuid4
4a733545
AS
3
4from .common import InfoExtractor
1e4fca9a 5from ..compat import compat_HTTPError, compat_str
67ca1a8e 6from ..utils import (
4a733545 7 ExtractorError,
67ca1a8e 8 int_or_none,
34921b43 9 join_nonempty,
67ca1a8e 10 try_get,
3052a30d 11 url_or_none,
4a733545
AS
12 urlencode_postdata,
13)
14
15
f6d7f7b4 16class ZattooPlatformBaseIE(InfoExtractor):
4a733545
AS
17 _power_guide_hash = None
18
f6d7f7b4 19 def _host_url(self):
16d896b2 20 return 'https://%s' % (self._API_HOST if hasattr(self, '_API_HOST') else self._HOST)
f6d7f7b4 21
52efa4b3 22 def _real_initialize(self):
23 if not self._power_guide_hash:
24 self.raise_login_required('An account is needed to access this media', method='password')
67ca1a8e 25
52efa4b3 26 def _perform_login(self, username, password):
67ca1a8e
S
27 try:
28 data = self._download_json(
f6d7f7b4 29 '%s/zapi/v2/account/login' % self._host_url(), None, 'Logging in',
67ca1a8e
S
30 data=urlencode_postdata({
31 'login': username,
32 'password': password,
33 'remember': 'true',
34 }), headers={
f6d7f7b4 35 'Referer': '%s/login' % self._host_url(),
67ca1a8e
S
36 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
37 })
38 except ExtractorError as e:
39 if isinstance(e.cause, compat_HTTPError) and e.cause.code == 400:
40 raise ExtractorError(
41 'Unable to login: incorrect username and/or password',
42 expected=True)
43 raise
44
45 self._power_guide_hash = data['session']['power_guide_hash']
46
52efa4b3 47 def _initialize_pre_login(self):
9b8b7a7b
AS
48 session_token = self._download_json(
49 f'{self._host_url()}/token.json', None, 'Downloading session token')['session_token']
67ca1a8e
S
50
51 # Will setup appropriate cookies
52 self._request_webpage(
9b8b7a7b 53 '%s/zapi/v3/session/hello' % self._host_url(), None,
67ca1a8e 54 'Opening session', data=urlencode_postdata({
67ca1a8e
S
55 'uuid': compat_str(uuid4()),
56 'lang': 'en',
9b8b7a7b 57 'app_version': '1.8.2',
67ca1a8e 58 'format': 'json',
9b8b7a7b 59 'client_app_token': session_token,
67ca1a8e 60 }))
4a733545 61
9b8b7a7b
AS
62 def _extract_video_id_from_recording(self, recid):
63 playlist = self._download_json(
64 f'{self._host_url()}/zapi/v2/playlist', recid, 'Downloading playlist')
65 try:
66 return next(
67 str(item['program_id']) for item in playlist['recordings']
68 if item.get('program_id') and str(item.get('id')) == recid)
69 except (StopIteration, KeyError):
70 raise ExtractorError('Could not extract video id from recording')
71
4a733545
AS
72 def _extract_cid(self, video_id, channel_name):
73 channel_groups = self._download_json(
f6d7f7b4 74 '%s/zapi/v2/cached/channels/%s' % (self._host_url(),
4a733545 75 self._power_guide_hash),
67ca1a8e 76 video_id, 'Downloading channel list',
4a733545
AS
77 query={'details': False})['channel_groups']
78 channel_list = []
79 for chgrp in channel_groups:
80 channel_list.extend(chgrp['channels'])
81 try:
82 return next(
83 chan['cid'] for chan in channel_list
67ca1a8e 84 if chan.get('cid') and (
3089bc74
S
85 chan.get('display_alias') == channel_name
86 or chan.get('cid') == channel_name))
4a733545
AS
87 except StopIteration:
88 raise ExtractorError('Could not extract channel id')
89
90 def _extract_cid_and_video_info(self, video_id):
91 data = self._download_json(
21160a17 92 '%s/zapi/v2/cached/program/power_details/%s' % (
f6d7f7b4 93 self._host_url(), self._power_guide_hash),
4a733545
AS
94 video_id,
95 'Downloading video information',
96 query={
21160a17
AS
97 'program_ids': video_id,
98 'complete': True,
4a733545
AS
99 })
100
21160a17 101 p = data['programs'][0]
67ca1a8e
S
102 cid = p['cid']
103
4a733545
AS
104 info_dict = {
105 'id': video_id,
21160a17
AS
106 'title': p.get('t') or p['et'],
107 'description': p.get('d'),
108 'thumbnail': p.get('i_url'),
67ca1a8e 109 'creator': p.get('channel_name'),
21160a17
AS
110 'episode': p.get('et'),
111 'episode_number': int_or_none(p.get('e_no')),
112 'season_number': int_or_none(p.get('s_no')),
67ca1a8e 113 'release_year': int_or_none(p.get('year')),
21160a17
AS
114 'categories': try_get(p, lambda x: x['c'], list),
115 'tags': try_get(p, lambda x: x['g'], list)
4a733545 116 }
67ca1a8e 117
4a733545
AS
118 return cid, info_dict
119
9b8b7a7b
AS
120 def _extract_ondemand_info(self, ondemand_id):
121 """
122 @returns (ondemand_token, ondemand_type, info_dict)
123 """
124 data = self._download_json(
125 '%s/zapi/vod/movies/%s' % (self._host_url(), ondemand_id),
126 ondemand_id, 'Downloading ondemand information')
127 info_dict = {
128 'id': ondemand_id,
129 'title': data.get('title'),
130 'description': data.get('description'),
131 'duration': int_or_none(data.get('duration')),
132 'release_year': int_or_none(data.get('year')),
133 'episode_number': int_or_none(data.get('episode_number')),
134 'season_number': int_or_none(data.get('season_number')),
135 'categories': try_get(data, lambda x: x['categories'], list),
136 }
137 return data['terms_catalog'][0]['terms'][0]['token'], data['type'], info_dict
138
139 def _extract_formats(self, cid, video_id, record_id=None, ondemand_id=None, ondemand_termtoken=None, ondemand_type=None, is_live=False):
67ca1a8e 140 postdata_common = {
4a733545
AS
141 'https_watch_urls': True,
142 }
4a733545
AS
143
144 if is_live:
67ca1a8e 145 postdata_common.update({'timeshift': 10800})
f6d7f7b4 146 url = '%s/zapi/watch/live/%s' % (self._host_url(), cid)
67ca1a8e 147 elif record_id:
f6d7f7b4 148 url = '%s/zapi/watch/recording/%s' % (self._host_url(), record_id)
9b8b7a7b
AS
149 elif ondemand_id:
150 postdata_common.update({
151 'teasable_id': ondemand_id,
152 'term_token': ondemand_termtoken,
153 'teasable_type': ondemand_type
154 })
155 url = '%s/zapi/watch/vod/video' % self._host_url()
67ca1a8e 156 else:
9b8b7a7b 157 url = '%s/zapi/v3/watch/replay/%s/%s' % (self._host_url(), cid, video_id)
4a733545 158 formats = []
9b8b7a7b
AS
159 subtitles = {}
160 for stream_type in ('dash', 'hls7'):
67ca1a8e
S
161 postdata = postdata_common.copy()
162 postdata['stream_type'] = stream_type
163
164 data = self._download_json(
165 url, video_id, 'Downloading %s formats' % stream_type.upper(),
166 data=urlencode_postdata(postdata), fatal=False)
167 if not data:
168 continue
169
170 watch_urls = try_get(
171 data, lambda x: x['stream']['watch_urls'], list)
172 if not watch_urls:
173 continue
174
175 for watch in watch_urls:
176 if not isinstance(watch, dict):
177 continue
3052a30d
S
178 watch_url = url_or_none(watch.get('url'))
179 if not watch_url:
67ca1a8e 180 continue
67ca1a8e 181 audio_channel = watch.get('audio_channel')
67ca1a8e 182 preference = 1 if audio_channel == 'A' else None
34921b43 183 format_id = join_nonempty(stream_type, watch.get('maxrate'), audio_channel)
9b8b7a7b
AS
184 if stream_type.startswith('dash'):
185 this_formats, subs = self._extract_mpd_formats_and_subtitles(
67ca1a8e 186 watch_url, video_id, mpd_id=format_id, fatal=False)
9b8b7a7b
AS
187 self._merge_subtitles(subs, target=subtitles)
188 elif stream_type.startswith('hls'):
189 this_formats, subs = self._extract_m3u8_formats_and_subtitles(
67ca1a8e
S
190 watch_url, video_id, 'mp4',
191 entry_protocol='m3u8_native', m3u8_id=format_id,
192 fatal=False)
9b8b7a7b 193 self._merge_subtitles(subs, target=subtitles)
67ca1a8e
S
194 elif stream_type == 'hds':
195 this_formats = self._extract_f4m_formats(
196 watch_url, video_id, f4m_id=format_id, fatal=False)
197 elif stream_type == 'smooth_playready':
198 this_formats = self._extract_ism_formats(
199 watch_url, video_id, ism_id=format_id, fatal=False)
200 else:
201 assert False
202 for this_format in this_formats:
f983b875 203 this_format['quality'] = preference
67ca1a8e 204 formats.extend(this_formats)
9b8b7a7b 205 return formats, subtitles
4a733545 206
9b8b7a7b
AS
207 def _extract_video(self, video_id, record_id=None):
208 cid, info_dict = self._extract_cid_and_video_info(video_id)
209 info_dict['formats'], info_dict['subtitles'] = self._extract_formats(cid, video_id, record_id=record_id)
4a733545
AS
210 return info_dict
211
9b8b7a7b
AS
212 def _extract_live(self, channel_name):
213 cid = self._extract_cid(channel_name, channel_name)
214 formats, subtitles = self._extract_formats(cid, cid, is_live=True)
215 return {
216 'id': channel_name,
217 'title': channel_name,
218 'is_live': True,
520876fa 219 'formats': formats,
9b8b7a7b
AS
220 'subtitles': subtitles
221 }
4a733545 222
9b8b7a7b
AS
223 def _extract_record(self, record_id):
224 video_id = self._extract_video_id_from_recording(record_id)
225 cid, info_dict = self._extract_cid_and_video_info(video_id)
226 info_dict['formats'], info_dict['subtitles'] = self._extract_formats(cid, video_id, record_id=record_id)
227 return info_dict
67ca1a8e 228
9b8b7a7b
AS
229 def _extract_ondemand(self, ondemand_id):
230 ondemand_termtoken, ondemand_type, info_dict = self._extract_ondemand_info(ondemand_id)
231 info_dict['formats'], info_dict['subtitles'] = self._extract_formats(
232 None, ondemand_id, ondemand_id=ondemand_id,
233 ondemand_termtoken=ondemand_termtoken, ondemand_type=ondemand_type)
234 return info_dict
67ca1a8e 235
1155ecef 236 def _real_extract(self, url):
48732bec 237 video_id, record_id = self._match_valid_url(url).groups()
f60ef663 238 return getattr(self, f'_extract_{self._TYPE}')(video_id or record_id)
1155ecef 239
4a733545 240
f60ef663
AS
241def _create_valid_url(host, match, qs, base_re=None):
242 match_base = fr'|{base_re}/(?P<vid1>{match})' if base_re else '(?P<vid1>)'
243 return rf'''(?x)https?://(?:www\.)?{re.escape(host)}/(?:
244 [^?#]+\?(?:[^#]+&)?{qs}=(?P<vid2>{match})
245 {match_base}
246 )'''
4a733545
AS
247
248
f6d7f7b4
S
249class ZattooBaseIE(ZattooPlatformBaseIE):
250 _NETRC_MACHINE = 'zattoo'
251 _HOST = 'zattoo.com'
252
f6d7f7b4 253
4a733545 254class ZattooIE(ZattooBaseIE):
f60ef663 255 _VALID_URL = _create_valid_url(ZattooBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
9b8b7a7b 256 _TYPE = 'video'
4a733545 257 _TESTS = [{
9b8b7a7b
AS
258 'url': 'https://zattoo.com/program/zdf/250170418',
259 'info_dict': {
260 'id': '250170418',
261 'ext': 'mp4',
262 'title': 'Markus Lanz',
263 'description': 'md5:e41cb1257de008ca62a73bb876ffa7fc',
264 'thumbnail': 're:http://images.zattic.com/cms/.+/format_480x360.jpg',
265 'creator': 'ZDF HD',
266 'release_year': 2022,
267 'episode': 'Folge 1655',
268 'categories': 'count:1',
269 'tags': 'count:2'
270 },
271 'params': {'skip_download': 'm3u8'}
272 }, {
273 'url': 'https://zattoo.com/program/daserste/210177916',
4a733545
AS
274 'only_matching': True,
275 }, {
9b8b7a7b 276 'url': 'https://zattoo.com/guide/german?channel=srf1&program=169860555',
4a733545
AS
277 'only_matching': True,
278 }]
279
4a733545
AS
280
281class ZattooLiveIE(ZattooBaseIE):
f60ef663 282 _VALID_URL = _create_valid_url(ZattooBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
9b8b7a7b
AS
283 _TYPE = 'live'
284 _TESTS = [{
285 'url': 'https://zattoo.com/channels/german?channel=srf_zwei',
4a733545 286 'only_matching': True,
9b8b7a7b
AS
287 }, {
288 'url': 'https://zattoo.com/live/srf1',
289 'only_matching': True,
290 }]
4a733545 291
67ca1a8e
S
292 @classmethod
293 def suitable(cls, url):
9b8b7a7b 294 return False if ZattooIE.suitable(url) else super().suitable(url)
67ca1a8e 295
9b8b7a7b
AS
296
297class ZattooMoviesIE(ZattooBaseIE):
f60ef663 298 _VALID_URL = _create_valid_url(ZattooBaseIE._HOST, r'\w+', 'movie_id', 'vod/movies')
9b8b7a7b
AS
299 _TYPE = 'ondemand'
300 _TESTS = [{
301 'url': 'https://zattoo.com/vod/movies/7521',
302 'only_matching': True,
303 }, {
304 'url': 'https://zattoo.com/ondemand?movie_id=7521&term_token=9f00f43183269484edde',
305 'only_matching': True,
306 }]
f6d7f7b4
S
307
308
9b8b7a7b 309class ZattooRecordingsIE(ZattooBaseIE):
f60ef663 310 _VALID_URL = _create_valid_url('zattoo.com', r'\d+', 'recording')
9b8b7a7b
AS
311 _TYPE = 'record'
312 _TESTS = [{
313 'url': 'https://zattoo.com/recordings?recording=193615508',
314 'only_matching': True,
315 }, {
316 'url': 'https://zattoo.com/tc/ptc_recordings_all_recordings?recording=193615420',
317 'only_matching': True,
318 }]
319
320
f60ef663 321class NetPlusTVBaseIE(ZattooPlatformBaseIE):
a831c2ea 322 _NETRC_MACHINE = 'netplus'
f6d7f7b4 323 _HOST = 'netplus.tv'
16d896b2 324 _API_HOST = 'www.%s' % _HOST
f6d7f7b4 325
f60ef663
AS
326
327class NetPlusTVIE(NetPlusTVBaseIE):
328 _VALID_URL = _create_valid_url(NetPlusTVBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
329 _TYPE = 'video'
330 _TESTS = [{
331 'url': 'https://netplus.tv/program/daserste/210177916',
332 'only_matching': True,
333 }, {
334 'url': 'https://netplus.tv/guide/german?channel=srf1&program=169860555',
335 'only_matching': True,
336 }]
337
338
339class NetPlusTVLiveIE(NetPlusTVBaseIE):
340 _VALID_URL = _create_valid_url(NetPlusTVBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
341 _TYPE = 'live'
f6d7f7b4 342 _TESTS = [{
f60ef663
AS
343 'url': 'https://netplus.tv/channels/german?channel=srf_zwei',
344 'only_matching': True,
345 }, {
346 'url': 'https://netplus.tv/live/srf1',
f6d7f7b4
S
347 'only_matching': True,
348 }]
349
f60ef663
AS
350 @classmethod
351 def suitable(cls, url):
352 return False if NetPlusTVIE.suitable(url) else super().suitable(url)
353
f6d7f7b4 354
f60ef663
AS
355class NetPlusTVRecordingsIE(NetPlusTVBaseIE):
356 _VALID_URL = _create_valid_url(NetPlusTVBaseIE._HOST, r'\d+', 'recording')
357 _TYPE = 'record'
358 _TESTS = [{
359 'url': 'https://netplus.tv/recordings?recording=193615508',
360 'only_matching': True,
361 }, {
362 'url': 'https://netplus.tv/tc/ptc_recordings_all_recordings?recording=193615420',
363 'only_matching': True,
364 }]
365
366
367class MNetTVBaseIE(ZattooPlatformBaseIE):
f6d7f7b4
S
368 _NETRC_MACHINE = 'mnettv'
369 _HOST = 'tvplus.m-net.de'
f6d7f7b4 370
f60ef663
AS
371
372class MNetTVIE(MNetTVBaseIE):
373 _VALID_URL = _create_valid_url(MNetTVBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
374 _TYPE = 'video'
375 _TESTS = [{
376 'url': 'https://tvplus.m-net.de/program/daserste/210177916',
377 'only_matching': True,
378 }, {
379 'url': 'https://tvplus.m-net.de/guide/german?channel=srf1&program=169860555',
380 'only_matching': True,
381 }]
382
383
384class MNetTVLiveIE(MNetTVBaseIE):
385 _VALID_URL = _create_valid_url(MNetTVBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
386 _TYPE = 'live'
387 _TESTS = [{
388 'url': 'https://tvplus.m-net.de/channels/german?channel=srf_zwei',
389 'only_matching': True,
390 }, {
391 'url': 'https://tvplus.m-net.de/live/srf1',
392 'only_matching': True,
393 }]
394
395 @classmethod
396 def suitable(cls, url):
397 return False if MNetTVIE.suitable(url) else super().suitable(url)
398
399
400class MNetTVRecordingsIE(MNetTVBaseIE):
401 _VALID_URL = _create_valid_url(MNetTVBaseIE._HOST, r'\d+', 'recording')
402 _TYPE = 'record'
f6d7f7b4 403 _TESTS = [{
f60ef663
AS
404 'url': 'https://tvplus.m-net.de/recordings?recording=193615508',
405 'only_matching': True,
406 }, {
407 'url': 'https://tvplus.m-net.de/tc/ptc_recordings_all_recordings?recording=193615420',
f6d7f7b4
S
408 'only_matching': True,
409 }]
410
411
f60ef663 412class WalyTVBaseIE(ZattooPlatformBaseIE):
f6d7f7b4
S
413 _NETRC_MACHINE = 'walytv'
414 _HOST = 'player.waly.tv'
f6d7f7b4 415
f60ef663
AS
416
417class WalyTVIE(WalyTVBaseIE):
418 _VALID_URL = _create_valid_url(WalyTVBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
419 _TYPE = 'video'
420 _TESTS = [{
421 'url': 'https://player.waly.tv/program/daserste/210177916',
422 'only_matching': True,
423 }, {
424 'url': 'https://player.waly.tv/guide/german?channel=srf1&program=169860555',
425 'only_matching': True,
426 }]
427
428
429class WalyTVLiveIE(WalyTVBaseIE):
430 _VALID_URL = _create_valid_url(WalyTVBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
431 _TYPE = 'live'
432 _TESTS = [{
433 'url': 'https://player.waly.tv/channels/german?channel=srf_zwei',
434 'only_matching': True,
435 }, {
436 'url': 'https://player.waly.tv/live/srf1',
437 'only_matching': True,
438 }]
439
440 @classmethod
441 def suitable(cls, url):
442 return False if WalyTVIE.suitable(url) else super().suitable(url)
443
444
445class WalyTVRecordingsIE(WalyTVBaseIE):
446 _VALID_URL = _create_valid_url(WalyTVBaseIE._HOST, r'\d+', 'recording')
447 _TYPE = 'record'
f6d7f7b4 448 _TESTS = [{
f60ef663
AS
449 'url': 'https://player.waly.tv/recordings?recording=193615508',
450 'only_matching': True,
451 }, {
452 'url': 'https://player.waly.tv/tc/ptc_recordings_all_recordings?recording=193615420',
f6d7f7b4
S
453 'only_matching': True,
454 }]
455
456
f60ef663 457class BBVTVBaseIE(ZattooPlatformBaseIE):
f6d7f7b4
S
458 _NETRC_MACHINE = 'bbvtv'
459 _HOST = 'bbv-tv.net'
16d896b2 460 _API_HOST = 'www.%s' % _HOST
f6d7f7b4 461
f60ef663
AS
462
463class BBVTVIE(BBVTVBaseIE):
464 _VALID_URL = _create_valid_url(BBVTVBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
465 _TYPE = 'video'
466 _TESTS = [{
467 'url': 'https://bbv-tv.net/program/daserste/210177916',
468 'only_matching': True,
469 }, {
470 'url': 'https://bbv-tv.net/guide/german?channel=srf1&program=169860555',
471 'only_matching': True,
472 }]
473
474
475class BBVTVLiveIE(BBVTVBaseIE):
476 _VALID_URL = _create_valid_url(BBVTVBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
477 _TYPE = 'live'
f6d7f7b4 478 _TESTS = [{
f60ef663
AS
479 'url': 'https://bbv-tv.net/channels/german?channel=srf_zwei',
480 'only_matching': True,
481 }, {
482 'url': 'https://bbv-tv.net/live/srf1',
f6d7f7b4
S
483 'only_matching': True,
484 }]
485
f60ef663
AS
486 @classmethod
487 def suitable(cls, url):
488 return False if BBVTVIE.suitable(url) else super().suitable(url)
f6d7f7b4 489
f60ef663
AS
490
491class BBVTVRecordingsIE(BBVTVBaseIE):
492 _VALID_URL = _create_valid_url(BBVTVBaseIE._HOST, r'\d+', 'recording')
493 _TYPE = 'record'
494 _TESTS = [{
495 'url': 'https://bbv-tv.net/recordings?recording=193615508',
496 'only_matching': True,
497 }, {
498 'url': 'https://bbv-tv.net/tc/ptc_recordings_all_recordings?recording=193615420',
499 'only_matching': True,
500 }]
501
502
503class VTXTVBaseIE(ZattooPlatformBaseIE):
f6d7f7b4
S
504 _NETRC_MACHINE = 'vtxtv'
505 _HOST = 'vtxtv.ch'
16d896b2 506 _API_HOST = 'www.%s' % _HOST
f6d7f7b4 507
f60ef663
AS
508
509class VTXTVIE(VTXTVBaseIE):
510 _VALID_URL = _create_valid_url(VTXTVBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
511 _TYPE = 'video'
512 _TESTS = [{
513 'url': 'https://vtxtv.ch/program/daserste/210177916',
514 'only_matching': True,
515 }, {
516 'url': 'https://vtxtv.ch/guide/german?channel=srf1&program=169860555',
517 'only_matching': True,
518 }]
519
520
521class VTXTVLiveIE(VTXTVBaseIE):
522 _VALID_URL = _create_valid_url(VTXTVBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
523 _TYPE = 'live'
524 _TESTS = [{
525 'url': 'https://vtxtv.ch/channels/german?channel=srf_zwei',
526 'only_matching': True,
527 }, {
528 'url': 'https://vtxtv.ch/live/srf1',
529 'only_matching': True,
530 }]
531
532 @classmethod
533 def suitable(cls, url):
534 return False if VTXTVIE.suitable(url) else super().suitable(url)
535
536
537class VTXTVRecordingsIE(VTXTVBaseIE):
538 _VALID_URL = _create_valid_url(VTXTVBaseIE._HOST, r'\d+', 'recording')
539 _TYPE = 'record'
f6d7f7b4 540 _TESTS = [{
f60ef663
AS
541 'url': 'https://vtxtv.ch/recordings?recording=193615508',
542 'only_matching': True,
543 }, {
544 'url': 'https://vtxtv.ch/tc/ptc_recordings_all_recordings?recording=193615420',
f6d7f7b4
S
545 'only_matching': True,
546 }]
547
548
f60ef663 549class GlattvisionTVBaseIE(ZattooPlatformBaseIE):
f6d7f7b4
S
550 _NETRC_MACHINE = 'glattvisiontv'
551 _HOST = 'iptv.glattvision.ch'
f6d7f7b4 552
f60ef663
AS
553
554class GlattvisionTVIE(GlattvisionTVBaseIE):
555 _VALID_URL = _create_valid_url(GlattvisionTVBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
556 _TYPE = 'video'
f6d7f7b4 557 _TESTS = [{
f60ef663
AS
558 'url': 'https://iptv.glattvision.ch/program/daserste/210177916',
559 'only_matching': True,
560 }, {
561 'url': 'https://iptv.glattvision.ch/guide/german?channel=srf1&program=169860555',
f6d7f7b4
S
562 'only_matching': True,
563 }]
564
565
f60ef663
AS
566class GlattvisionTVLiveIE(GlattvisionTVBaseIE):
567 _VALID_URL = _create_valid_url(GlattvisionTVBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
568 _TYPE = 'live'
569 _TESTS = [{
570 'url': 'https://iptv.glattvision.ch/channels/german?channel=srf_zwei',
571 'only_matching': True,
572 }, {
573 'url': 'https://iptv.glattvision.ch/live/srf1',
574 'only_matching': True,
575 }]
576
577 @classmethod
578 def suitable(cls, url):
579 return False if GlattvisionTVIE.suitable(url) else super().suitable(url)
580
581
582class GlattvisionTVRecordingsIE(GlattvisionTVBaseIE):
583 _VALID_URL = _create_valid_url(GlattvisionTVBaseIE._HOST, r'\d+', 'recording')
584 _TYPE = 'record'
585 _TESTS = [{
586 'url': 'https://iptv.glattvision.ch/recordings?recording=193615508',
587 'only_matching': True,
588 }, {
589 'url': 'https://iptv.glattvision.ch/tc/ptc_recordings_all_recordings?recording=193615420',
590 'only_matching': True,
591 }]
592
593
594class SAKTVBaseIE(ZattooPlatformBaseIE):
f6d7f7b4
S
595 _NETRC_MACHINE = 'saktv'
596 _HOST = 'saktv.ch'
16d896b2 597 _API_HOST = 'www.%s' % _HOST
f6d7f7b4 598
f60ef663
AS
599
600class SAKTVIE(SAKTVBaseIE):
601 _VALID_URL = _create_valid_url(SAKTVBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
602 _TYPE = 'video'
603 _TESTS = [{
604 'url': 'https://saktv.ch/program/daserste/210177916',
605 'only_matching': True,
606 }, {
607 'url': 'https://saktv.ch/guide/german?channel=srf1&program=169860555',
608 'only_matching': True,
609 }]
610
611
612class SAKTVLiveIE(SAKTVBaseIE):
613 _VALID_URL = _create_valid_url(SAKTVBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
614 _TYPE = 'live'
f6d7f7b4 615 _TESTS = [{
f60ef663
AS
616 'url': 'https://saktv.ch/channels/german?channel=srf_zwei',
617 'only_matching': True,
618 }, {
619 'url': 'https://saktv.ch/live/srf1',
f6d7f7b4
S
620 'only_matching': True,
621 }]
622
f60ef663
AS
623 @classmethod
624 def suitable(cls, url):
625 return False if SAKTVIE.suitable(url) else super().suitable(url)
626
f6d7f7b4 627
f60ef663
AS
628class SAKTVRecordingsIE(SAKTVBaseIE):
629 _VALID_URL = _create_valid_url(SAKTVBaseIE._HOST, r'\d+', 'recording')
630 _TYPE = 'record'
631 _TESTS = [{
632 'url': 'https://saktv.ch/recordings?recording=193615508',
633 'only_matching': True,
634 }, {
635 'url': 'https://saktv.ch/tc/ptc_recordings_all_recordings?recording=193615420',
636 'only_matching': True,
637 }]
638
639
640class EWETVBaseIE(ZattooPlatformBaseIE):
f6d7f7b4
S
641 _NETRC_MACHINE = 'ewetv'
642 _HOST = 'tvonline.ewe.de'
f6d7f7b4 643
f60ef663
AS
644
645class EWETVIE(EWETVBaseIE):
646 _VALID_URL = _create_valid_url(EWETVBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
647 _TYPE = 'video'
648 _TESTS = [{
649 'url': 'https://tvonline.ewe.de/program/daserste/210177916',
650 'only_matching': True,
651 }, {
652 'url': 'https://tvonline.ewe.de/guide/german?channel=srf1&program=169860555',
653 'only_matching': True,
654 }]
655
656
657class EWETVLiveIE(EWETVBaseIE):
658 _VALID_URL = _create_valid_url(EWETVBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
659 _TYPE = 'live'
660 _TESTS = [{
661 'url': 'https://tvonline.ewe.de/channels/german?channel=srf_zwei',
662 'only_matching': True,
663 }, {
664 'url': 'https://tvonline.ewe.de/live/srf1',
665 'only_matching': True,
666 }]
667
668 @classmethod
669 def suitable(cls, url):
670 return False if EWETVIE.suitable(url) else super().suitable(url)
671
672
673class EWETVRecordingsIE(EWETVBaseIE):
674 _VALID_URL = _create_valid_url(EWETVBaseIE._HOST, r'\d+', 'recording')
675 _TYPE = 'record'
f6d7f7b4 676 _TESTS = [{
f60ef663
AS
677 'url': 'https://tvonline.ewe.de/recordings?recording=193615508',
678 'only_matching': True,
679 }, {
680 'url': 'https://tvonline.ewe.de/tc/ptc_recordings_all_recordings?recording=193615420',
f6d7f7b4
S
681 'only_matching': True,
682 }]
683
684
f60ef663 685class QuantumTVBaseIE(ZattooPlatformBaseIE):
f6d7f7b4
S
686 _NETRC_MACHINE = 'quantumtv'
687 _HOST = 'quantum-tv.com'
16d896b2 688 _API_HOST = 'www.%s' % _HOST
f6d7f7b4 689
f60ef663
AS
690
691class QuantumTVIE(QuantumTVBaseIE):
692 _VALID_URL = _create_valid_url(QuantumTVBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
693 _TYPE = 'video'
f6d7f7b4 694 _TESTS = [{
f60ef663
AS
695 'url': 'https://quantum-tv.com/program/daserste/210177916',
696 'only_matching': True,
697 }, {
698 'url': 'https://quantum-tv.com/guide/german?channel=srf1&program=169860555',
699 'only_matching': True,
700 }]
701
702
703class QuantumTVLiveIE(QuantumTVBaseIE):
704 _VALID_URL = _create_valid_url(QuantumTVBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
705 _TYPE = 'live'
706 _TESTS = [{
707 'url': 'https://quantum-tv.com/channels/german?channel=srf_zwei',
708 'only_matching': True,
709 }, {
710 'url': 'https://quantum-tv.com/live/srf1',
711 'only_matching': True,
712 }]
713
714 @classmethod
715 def suitable(cls, url):
716 return False if QuantumTVIE.suitable(url) else super().suitable(url)
717
718
719class QuantumTVRecordingsIE(QuantumTVBaseIE):
720 _VALID_URL = _create_valid_url(QuantumTVBaseIE._HOST, r'\d+', 'recording')
721 _TYPE = 'record'
722 _TESTS = [{
723 'url': 'https://quantum-tv.com/recordings?recording=193615508',
724 'only_matching': True,
725 }, {
726 'url': 'https://quantum-tv.com/tc/ptc_recordings_all_recordings?recording=193615420',
f6d7f7b4
S
727 'only_matching': True,
728 }]
729
730
f60ef663 731class OsnatelTVBaseIE(ZattooPlatformBaseIE):
f6d7f7b4 732 _NETRC_MACHINE = 'osnateltv'
2004e221 733 _HOST = 'tvonline.osnatel.de'
f6d7f7b4 734
f60ef663
AS
735
736class OsnatelTVIE(OsnatelTVBaseIE):
737 _VALID_URL = _create_valid_url(OsnatelTVBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
738 _TYPE = 'video'
739 _TESTS = [{
740 'url': 'https://tvonline.osnatel.de/program/daserste/210177916',
741 'only_matching': True,
742 }, {
743 'url': 'https://tvonline.osnatel.de/guide/german?channel=srf1&program=169860555',
744 'only_matching': True,
745 }]
746
747
748class OsnatelTVLiveIE(OsnatelTVBaseIE):
749 _VALID_URL = _create_valid_url(OsnatelTVBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
750 _TYPE = 'live'
f6d7f7b4 751 _TESTS = [{
f60ef663
AS
752 'url': 'https://tvonline.osnatel.de/channels/german?channel=srf_zwei',
753 'only_matching': True,
754 }, {
755 'url': 'https://tvonline.osnatel.de/live/srf1',
f6d7f7b4
S
756 'only_matching': True,
757 }]
758
f60ef663
AS
759 @classmethod
760 def suitable(cls, url):
761 return False if OsnatelTVIE.suitable(url) else super().suitable(url)
f6d7f7b4 762
f60ef663
AS
763
764class OsnatelTVRecordingsIE(OsnatelTVBaseIE):
765 _VALID_URL = _create_valid_url(OsnatelTVBaseIE._HOST, r'\d+', 'recording')
766 _TYPE = 'record'
767 _TESTS = [{
768 'url': 'https://tvonline.osnatel.de/recordings?recording=193615508',
769 'only_matching': True,
770 }, {
771 'url': 'https://tvonline.osnatel.de/tc/ptc_recordings_all_recordings?recording=193615420',
772 'only_matching': True,
773 }]
774
775
776class EinsUndEinsTVBaseIE(ZattooPlatformBaseIE):
f6d7f7b4
S
777 _NETRC_MACHINE = '1und1tv'
778 _HOST = '1und1.tv'
16d896b2 779 _API_HOST = 'www.%s' % _HOST
f6d7f7b4 780
f60ef663
AS
781
782class EinsUndEinsTVIE(EinsUndEinsTVBaseIE):
783 _VALID_URL = _create_valid_url(EinsUndEinsTVBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
784 _TYPE = 'video'
f6d7f7b4 785 _TESTS = [{
f60ef663
AS
786 'url': 'https://1und1.tv/program/daserste/210177916',
787 'only_matching': True,
788 }, {
789 'url': 'https://1und1.tv/guide/german?channel=srf1&program=169860555',
f6d7f7b4
S
790 'only_matching': True,
791 }]
a81daba2
AS
792
793
f60ef663
AS
794class EinsUndEinsTVLiveIE(EinsUndEinsTVBaseIE):
795 _VALID_URL = _create_valid_url(EinsUndEinsTVBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
796 _TYPE = 'live'
797 _TESTS = [{
798 'url': 'https://1und1.tv/channels/german?channel=srf_zwei',
799 'only_matching': True,
800 }, {
801 'url': 'https://1und1.tv/live/srf1',
802 'only_matching': True,
803 }]
804
805 @classmethod
806 def suitable(cls, url):
807 return False if EinsUndEinsTVIE.suitable(url) else super().suitable(url)
808
809
810class EinsUndEinsTVRecordingsIE(EinsUndEinsTVBaseIE):
811 _VALID_URL = _create_valid_url(EinsUndEinsTVBaseIE._HOST, r'\d+', 'recording')
812 _TYPE = 'record'
813 _TESTS = [{
814 'url': 'https://1und1.tv/recordings?recording=193615508',
815 'only_matching': True,
816 }, {
817 'url': 'https://1und1.tv/tc/ptc_recordings_all_recordings?recording=193615420',
818 'only_matching': True,
819 }]
820
821
822class SaltTVBaseIE(ZattooPlatformBaseIE):
a81daba2
AS
823 _NETRC_MACHINE = 'salttv'
824 _HOST = 'tv.salt.ch'
a81daba2 825
f60ef663
AS
826
827class SaltTVIE(SaltTVBaseIE):
828 _VALID_URL = _create_valid_url(SaltTVBaseIE._HOST, r'\d+', 'program', '(?:program|watch)/[^/]+')
829 _TYPE = 'video'
830 _TESTS = [{
831 'url': 'https://tv.salt.ch/program/daserste/210177916',
832 'only_matching': True,
833 }, {
834 'url': 'https://tv.salt.ch/guide/german?channel=srf1&program=169860555',
835 'only_matching': True,
836 }]
837
838
839class SaltTVLiveIE(SaltTVBaseIE):
840 _VALID_URL = _create_valid_url(SaltTVBaseIE._HOST, r'[^/?&#]+', 'channel', 'live')
841 _TYPE = 'live'
a81daba2 842 _TESTS = [{
f60ef663
AS
843 'url': 'https://tv.salt.ch/channels/german?channel=srf_zwei',
844 'only_matching': True,
845 }, {
846 'url': 'https://tv.salt.ch/live/srf1',
847 'only_matching': True,
848 }]
849
850 @classmethod
851 def suitable(cls, url):
852 return False if SaltTVIE.suitable(url) else super().suitable(url)
853
854
855class SaltTVRecordingsIE(SaltTVBaseIE):
856 _VALID_URL = _create_valid_url(SaltTVBaseIE._HOST, r'\d+', 'recording')
857 _TYPE = 'record'
858 _TESTS = [{
859 'url': 'https://tv.salt.ch/recordings?recording=193615508',
860 'only_matching': True,
861 }, {
862 'url': 'https://tv.salt.ch/tc/ptc_recordings_all_recordings?recording=193615420',
a81daba2
AS
863 'only_matching': True,
864 }]