3 from .common
import InfoExtractor
22 class TVPlayIE(InfoExtractor
):
24 IE_DESC
= 'MTG services'
31 tvplay(?:\.skaties)?\.lv(?:/parraides)?|
32 (?:tv3play|play\.tv3)\.lt(?:/programos)?|
33 tv3play(?:\.tv3)?\.ee/sisu|
34 (?:tv(?:3|6|8|10)play)\.se/program|
35 (?:(?:tv3play|viasat4play|tv6play)\.no|(?:tv3play)\.dk)/programmer|
36 play\.nova(?:tv)?\.bg/programi
44 'url': 'http://www.tvplay.lv/parraides/vinas-melo-labak/418113?autostart=true',
45 'md5': 'a1612fe0849455423ad8718fe049be21',
49 'title': 'Kādi ir īri? - Viņas melo labāk',
50 'description': 'Baiba apsmej īrus, kādi tie ir un ko viņi dara.',
51 'series': 'Viņas melo labāk',
55 'timestamp': 1406097056,
56 'upload_date': '20140723',
60 'url': 'http://play.tv3.lt/programos/moterys-meluoja-geriau/409229?autostart=true',
64 'title': 'Moterys meluoja geriau',
65 'description': 'md5:9aec0fc68e2cbc992d2a140bd41fa89e',
66 'series': 'Moterys meluoja geriau',
68 'season': '1 sezonas',
71 'timestamp': 1403769181,
72 'upload_date': '20140626',
76 'skip_download': True,
80 'url': 'http://www.tv3play.ee/sisu/kodu-keset-linna/238551?autostart=true',
84 'title': 'Kodu keset linna 398537',
85 'description': 'md5:7df175e3c94db9e47c0d81ffa5d68701',
87 'timestamp': 1292449761,
88 'upload_date': '20101215',
92 'skip_download': True,
96 'url': 'http://www.tv3play.se/program/husraddarna/395385?autostart=true',
100 'title': 'Husräddarna S02E07',
101 'description': 'md5:f210c6c89f42d4fc39faa551be813777',
103 'timestamp': 1400596321,
104 'upload_date': '20140520',
107 'skip_download': True,
111 'url': 'http://www.tv6play.se/program/den-sista-dokusapan/266636?autostart=true',
115 'title': 'Den sista dokusåpan S01E08',
116 'description': 'md5:295be39c872520221b933830f660b110',
118 'timestamp': 1330522854,
119 'upload_date': '20120229',
123 'skip_download': True,
127 'url': 'http://www.tv8play.se/program/antikjakten/282756?autostart=true',
131 'title': 'Antikjakten S01E10',
132 'description': 'md5:1b201169beabd97e20c5ad0ad67b13b8',
134 'timestamp': 1348575868,
135 'upload_date': '20120925',
138 'skip_download': True,
142 'url': 'http://www.tv3play.no/programmer/anna-anka-soker-assistent/230898?autostart=true',
146 'title': 'Anna Anka søker assistent - Ep. 8',
147 'description': 'md5:f80916bf5bbe1c5f760d127f8dd71474',
149 'timestamp': 1277720005,
150 'upload_date': '20100628',
153 'skip_download': True,
157 'url': 'http://www.viasat4play.no/programmer/budbringerne/21873?autostart=true',
161 'title': 'Budbringerne program 10',
162 'description': 'md5:4db78dc4ec8a85bb04fd322a3ee5092d',
164 'timestamp': 1254205102,
165 'upload_date': '20090929',
168 'skip_download': True,
172 'url': 'http://www.tv6play.no/programmer/hotelinspektor-alex-polizzi/361883?autostart=true',
176 'title': 'Hotelinspektør Alex Polizzi - Ep. 10',
177 'description': 'md5:3ecf808db9ec96c862c8ecb3a7fdaf81',
179 'timestamp': 1393236292,
180 'upload_date': '20140224',
183 'skip_download': True,
187 'url': 'http://play.novatv.bg/programi/zdravei-bulgariya/624952?autostart=true',
191 'title': 'Здравей, България (12.06.2015 г.) ',
192 'description': 'md5:99f3700451ac5bb71a260268b8daefd7',
194 'timestamp': 1434100372,
195 'upload_date': '20150612',
199 'skip_download': True,
203 'url': 'https://play.nova.bg/programi/zdravei-bulgariya/764300?autostart=true',
204 'only_matching': True,
207 'url': 'http://tvplay.skaties.lv/parraides/vinas-melo-labak/418113?autostart=true',
208 'only_matching': True,
211 'url': 'https://tvplay.skaties.lv/vinas-melo-labak/418113/?autostart=true',
212 'only_matching': True,
216 'url': 'http://tvplay.skaties.lv/parraides/tv3-zinas/760183',
217 'only_matching': True,
220 'url': 'http://tv3play.tv3.ee/sisu/kodu-keset-linna/238551?autostart=true',
221 'only_matching': True,
225 'only_matching': True,
229 def _real_extract(self
, url
):
230 video_id
= self
._match
_id
(url
)
231 geo_country
= self
._search
_regex
(
232 r
'https?://[^/]+\.([a-z]{2})', url
,
233 'geo country', default
=None)
235 self
._initialize
_geo
_bypass
({'countries': [geo_country.upper()]}
)
236 video
= self
._download
_json
(
237 'http://playapi.mtgx.tv/v3/videos/%s' % video_id
, video_id
, 'Downloading video JSON')
239 title
= video
['title']
242 streams
= self
._download
_json
(
243 'http://playapi.mtgx.tv/v3/videos/stream/%s' % video_id
,
244 video_id
, 'Downloading streams JSON')
245 except ExtractorError
as e
:
246 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
247 msg
= self
._parse
_json
(e
.cause
.read().decode('utf-8'), video_id
)
248 raise ExtractorError(msg
['msg'], expected
=True)
251 quality
= qualities(['hls', 'medium', 'high'])
253 for format_id
, video_url
in streams
.get('streams', {}).items():
254 video_url
= url_or_none(video_url
)
257 ext
= determine_ext(video_url
)
259 formats
.extend(self
._extract
_f
4m
_formats
(
260 update_url_query(video_url
, {
262 'plugin': 'aasp-3.5.0.151.81'
263 }), video_id
, f4m_id
='hds', fatal
=False))
265 formats
.extend(self
._extract
_m
3u8_formats
(
266 video_url
, video_id
, 'mp4', 'm3u8_native',
267 m3u8_id
='hls', fatal
=False))
270 'format_id': format_id
,
271 'quality': quality(format_id
),
274 if video_url
.startswith('rtmp'):
276 r
'^(?P<url>rtmp://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', video_url
)
281 'url': m
.group('url'),
282 'app': m
.group('app'),
283 'play_path': m
.group('playpath'),
292 if not formats
and video
.get('is_geo_blocked'):
293 self
.raise_geo_restricted(
294 'This content might not be available in your country due to copyright reasons',
295 metadata_available
=True)
297 # TODO: webvtt in m3u8
299 sami_path
= video
.get('sami_path')
301 lang
= self
._search
_regex
(
302 r
'_([a-z]{2})\.xml', sami_path
, 'lang',
303 default
=compat_urlparse
.urlparse(url
).netloc
.rsplit('.', 1)[-1])
308 series
= video
.get('format_title')
309 episode_number
= int_or_none(video
.get('format_position', {}).get('episode'))
310 season
= video
.get('_embedded', {}).get('season', {}
).get('title')
311 season_number
= int_or_none(video
.get('format_position', {}).get('season'))
316 'description': video
.get('description'),
318 'episode_number': episode_number
,
320 'season_number': season_number
,
321 'duration': int_or_none(video
.get('duration')),
322 'timestamp': parse_iso8601(video
.get('created_at')),
323 'view_count': try_get(video
, lambda x
: x
['views']['total'], int),
324 'age_limit': int_or_none(video
.get('age_limit', 0)),
326 'subtitles': subtitles
,
330 class ViafreeIE(InfoExtractor
):
331 _VALID_URL
= r
'''(?x)
334 viafree\.(?P<country>dk|no|se|fi)
335 /(?P<id>(?:program(?:mer)?|ohjelmat)?/(?:[^/]+/)+[^/?#&]+)
338 'url': 'http://www.viafree.no/programmer/underholdning/det-beste-vorspielet/sesong-2/episode-1',
342 'title': 'Det beste vorspielet - Sesong 2 - Episode 1',
343 'description': 'md5:b632cb848331404ccacd8cd03e83b4c3',
344 'series': 'Det beste vorspielet',
347 'timestamp': 1471200600,
348 'upload_date': '20160814',
351 'skip_download': True,
354 'url': 'https://www.viafree.dk/programmer/humor/comedy-central-roast-of-charlie-sheen/film/1047660',
358 'title': 'Comedy Central Roast of Charlie Sheen - Comedy Central Roast of Charlie Sheen',
359 'description': 'md5:ec956d941ae9fd7c65a48fd64951dc6d',
360 'series': 'Comedy Central Roast of Charlie Sheen',
363 'timestamp': 1608246060,
364 'upload_date': '20201217'
367 'skip_download': True
371 'url': 'http://www.viafree.se/program/reality/sommaren-med-youtube-stjarnorna/sasong-1/avsnitt-1',
372 'only_matching': True,
374 # Different og:image URL schema
375 'url': 'http://www.viafree.se/program/reality/sommaren-med-youtube-stjarnorna/sasong-1/avsnitt-2',
376 'only_matching': True,
378 'url': 'http://www.viafree.se/program/livsstil/husraddarna/sasong-2/avsnitt-2',
379 'only_matching': True,
381 'url': 'http://www.viafree.dk/programmer/reality/paradise-hotel/saeson-7/episode-5',
382 'only_matching': True,
384 'url': 'http://www.viafree.se/program/underhallning/i-like-radio-live/sasong-1/676869',
385 'only_matching': True,
387 'url': 'https://www.viafree.fi/ohjelmat/entertainment/amazing-makeovers/kausi-7/jakso-2',
388 'only_matching': True,
392 def _real_extract(self
, url
):
393 country
, path
= self
._match
_valid
_url
(url
).groups()
394 content
= self
._download
_json
(
395 'https://viafree-content.mtg-api.com/viafree-content/v1/%s/path/%s' % (country
, path
), path
)
396 program
= content
['_embedded']['viafreeBlocks'][0]['_embedded']['program']
397 guid
= program
['guid']
398 meta
= content
['meta']
399 title
= meta
['title']
402 stream_href
= self
._download
_json
(
403 program
['_links']['streamLink']['href'], guid
,
404 headers
=self
.geo_verification_headers())['embedded']['prioritizedStreams'][0]['links']['stream']['href']
405 except ExtractorError
as e
:
406 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
407 self
.raise_geo_restricted(countries
=[country
])
410 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(stream_href
, guid
, 'mp4')
411 episode
= program
.get('episode') or {}
415 'thumbnail': meta
.get('image'),
416 'description': meta
.get('description'),
417 'series': episode
.get('seriesTitle'),
418 'subtitles': subtitles
,
419 'episode_number': int_or_none(episode
.get('episodeNumber')),
420 'season_number': int_or_none(episode
.get('seasonNumber')),
421 'duration': int_or_none(try_get(program
, lambda x
: x
['video']['duration']['milliseconds']), 1000),
422 'timestamp': parse_iso8601(try_get(program
, lambda x
: x
['availability']['start'])),
427 class TVPlayHomeIE(InfoExtractor
):
428 _VALID_URL
= r
'''(?x)
431 play\.(?:tv3|skaties)\.(?P<country>lv|lt|ee)/
433 [^?#&]+(?:episode|programme|clip)-(?P<id>\d+)
436 'url': 'https://play.tv3.lt/series/gauju-karai-karveliai,serial-2343791/serija-8,episode-2343828',
440 'title': 'Gaujų karai. Karveliai (2021) | S01E08: Serija 8',
441 'description': 'md5:f6fcfbb236429f05531131640dfa7c81',
443 'season': 'Gaujų karai. Karveliai',
445 'release_year': 2021,
446 'episode': 'Serija 8',
450 'skip_download': 'm3u8',
453 'url': 'https://play.tv3.lt/series/moterys-meluoja-geriau-n-7,serial-2574652/serija-25,episode-3284937',
457 'season': 'Moterys meluoja geriau [N-7]',
459 'release_year': 2021,
460 'episode': 'Serija 25',
461 'episode_number': 25,
462 'title': 'Moterys meluoja geriau [N-7] (2021) | S14|E25: Serija 25',
463 'description': 'md5:c6926e9710f1a126f028fbe121eddb79',
468 'url': 'https://play.tv3.lt/lives/tv6-lt,live-2838694/optibet-a-lygos-rungtynes-marijampoles-suduva--vilniaus-riteriai,programme-3422014',
469 'only_matching': True,
471 'url': 'https://tv3play.skaties.lv/series/women-lie-better-lv,serial-1024464/women-lie-better-lv,episode-1038762',
472 'only_matching': True,
474 'url': 'https://play.tv3.ee/series/_,serial-2654462/_,episode-2654474',
475 'only_matching': True,
477 'url': 'https://tv3play.skaties.lv/clips/tv3-zinas-valsti-lidz-15novembrim-bus-majsede,clip-3464509',
478 'only_matching': True,
481 def _real_extract(self
, url
):
482 country
, is_live
, video_id
= self
._match
_valid
_url
(url
).groups()
484 api_path
= 'lives/programmes' if is_live
else 'vods'
485 data
= self
._download
_json
(
486 urljoin(url
, f
'/api/products/{api_path}/{video_id}?platform=BROWSER&lang={country.upper()}'),
489 video_type
= 'CATCHUP' if is_live
else 'MOVIE'
490 stream_id
= data
['programRecordingId'] if is_live
else video_id
491 stream
= self
._download
_json
(
492 urljoin(url
, f
'/api/products/{stream_id}/videos/playlist?videoType={video_type}&platform=BROWSER'), video_id
)
493 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(
494 stream
['sources']['HLS'][0]['src'], video_id
, 'mp4', 'm3u8_native', m3u8_id
='hls')
496 thumbnails
= set(traverse_obj(
497 data
, (('galary', 'images', 'artworks'), ..., ..., ('miniUrl', 'mainUrl')), expected_type
=url_or_none
))
501 'title': self
._resolve
_title
(data
),
502 'description': traverse_obj(data
, 'description', 'lead'),
503 'duration': int_or_none(data
.get('duration')),
504 'season': traverse_obj(data
, ('season', 'serial', 'title')),
505 'season_number': int_or_none(traverse_obj(data
, ('season', 'number'))),
506 'episode': data
.get('title'),
507 'episode_number': int_or_none(data
.get('episode')),
508 'release_year': int_or_none(traverse_obj(data
, ('season', 'serial', 'year'))),
509 'thumbnails': [{'url': url, 'ext': 'jpg'}
for url
in thumbnails
],
511 'subtitles': subtitles
,
515 def _resolve_title(data
):
516 return try_get(data
, lambda x
: (
517 f
'{data["season"]["serial"]["title"]} ({data["season"]["serial"]["year"]}) | '
518 f
'S{data["season"]["number"]:02d}E{data["episode"]:02d}: {data["title"]}'
519 )) or data
.get('title')