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 self
._sort
_formats
(formats
)
299 # TODO: webvtt in m3u8
301 sami_path
= video
.get('sami_path')
303 lang
= self
._search
_regex
(
304 r
'_([a-z]{2})\.xml', sami_path
, 'lang',
305 default
=compat_urlparse
.urlparse(url
).netloc
.rsplit('.', 1)[-1])
310 series
= video
.get('format_title')
311 episode_number
= int_or_none(video
.get('format_position', {}).get('episode'))
312 season
= video
.get('_embedded', {}).get('season', {}
).get('title')
313 season_number
= int_or_none(video
.get('format_position', {}).get('season'))
318 'description': video
.get('description'),
320 'episode_number': episode_number
,
322 'season_number': season_number
,
323 'duration': int_or_none(video
.get('duration')),
324 'timestamp': parse_iso8601(video
.get('created_at')),
325 'view_count': try_get(video
, lambda x
: x
['views']['total'], int),
326 'age_limit': int_or_none(video
.get('age_limit', 0)),
328 'subtitles': subtitles
,
332 class ViafreeIE(InfoExtractor
):
333 _VALID_URL
= r
'''(?x)
336 viafree\.(?P<country>dk|no|se|fi)
337 /(?P<id>(?:program(?:mer)?|ohjelmat)?/(?:[^/]+/)+[^/?#&]+)
340 'url': 'http://www.viafree.no/programmer/underholdning/det-beste-vorspielet/sesong-2/episode-1',
344 'title': 'Det beste vorspielet - Sesong 2 - Episode 1',
345 'description': 'md5:b632cb848331404ccacd8cd03e83b4c3',
346 'series': 'Det beste vorspielet',
349 'timestamp': 1471200600,
350 'upload_date': '20160814',
353 'skip_download': True,
356 'url': 'https://www.viafree.dk/programmer/humor/comedy-central-roast-of-charlie-sheen/film/1047660',
360 'title': 'Comedy Central Roast of Charlie Sheen - Comedy Central Roast of Charlie Sheen',
361 'description': 'md5:ec956d941ae9fd7c65a48fd64951dc6d',
362 'series': 'Comedy Central Roast of Charlie Sheen',
365 'timestamp': 1608246060,
366 'upload_date': '20201217'
369 'skip_download': True
373 'url': 'http://www.viafree.se/program/reality/sommaren-med-youtube-stjarnorna/sasong-1/avsnitt-1',
374 'only_matching': True,
376 # Different og:image URL schema
377 'url': 'http://www.viafree.se/program/reality/sommaren-med-youtube-stjarnorna/sasong-1/avsnitt-2',
378 'only_matching': True,
380 'url': 'http://www.viafree.se/program/livsstil/husraddarna/sasong-2/avsnitt-2',
381 'only_matching': True,
383 'url': 'http://www.viafree.dk/programmer/reality/paradise-hotel/saeson-7/episode-5',
384 'only_matching': True,
386 'url': 'http://www.viafree.se/program/underhallning/i-like-radio-live/sasong-1/676869',
387 'only_matching': True,
389 'url': 'https://www.viafree.fi/ohjelmat/entertainment/amazing-makeovers/kausi-7/jakso-2',
390 'only_matching': True,
394 def _real_extract(self
, url
):
395 country
, path
= self
._match
_valid
_url
(url
).groups()
396 content
= self
._download
_json
(
397 'https://viafree-content.mtg-api.com/viafree-content/v1/%s/path/%s' % (country
, path
), path
)
398 program
= content
['_embedded']['viafreeBlocks'][0]['_embedded']['program']
399 guid
= program
['guid']
400 meta
= content
['meta']
401 title
= meta
['title']
404 stream_href
= self
._download
_json
(
405 program
['_links']['streamLink']['href'], guid
,
406 headers
=self
.geo_verification_headers())['embedded']['prioritizedStreams'][0]['links']['stream']['href']
407 except ExtractorError
as e
:
408 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
409 self
.raise_geo_restricted(countries
=[country
])
412 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(stream_href
, guid
, 'mp4')
413 self
._sort
_formats
(formats
)
414 episode
= program
.get('episode') or {}
418 'thumbnail': meta
.get('image'),
419 'description': meta
.get('description'),
420 'series': episode
.get('seriesTitle'),
421 'subtitles': subtitles
,
422 'episode_number': int_or_none(episode
.get('episodeNumber')),
423 'season_number': int_or_none(episode
.get('seasonNumber')),
424 'duration': int_or_none(try_get(program
, lambda x
: x
['video']['duration']['milliseconds']), 1000),
425 'timestamp': parse_iso8601(try_get(program
, lambda x
: x
['availability']['start'])),
430 class TVPlayHomeIE(InfoExtractor
):
431 _VALID_URL
= r
'''(?x)
434 play\.(?:tv3|skaties)\.(?P<country>lv|lt|ee)/
436 [^?#&]+(?:episode|programme|clip)-(?P<id>\d+)
439 'url': 'https://play.tv3.lt/series/gauju-karai-karveliai,serial-2343791/serija-8,episode-2343828',
443 'title': 'Gaujų karai. Karveliai (2021) | S01E08: Serija 8',
444 'description': 'md5:f6fcfbb236429f05531131640dfa7c81',
446 'season': 'Gaujų karai. Karveliai',
448 'release_year': 2021,
449 'episode': 'Serija 8',
453 'skip_download': 'm3u8',
456 'url': 'https://play.tv3.lt/series/moterys-meluoja-geriau-n-7,serial-2574652/serija-25,episode-3284937',
460 'season': 'Moterys meluoja geriau [N-7]',
462 'release_year': 2021,
463 'episode': 'Serija 25',
464 'episode_number': 25,
465 'title': 'Moterys meluoja geriau [N-7] (2021) | S14|E25: Serija 25',
466 'description': 'md5:c6926e9710f1a126f028fbe121eddb79',
471 'url': 'https://play.tv3.lt/lives/tv6-lt,live-2838694/optibet-a-lygos-rungtynes-marijampoles-suduva--vilniaus-riteriai,programme-3422014',
472 'only_matching': True,
474 'url': 'https://tv3play.skaties.lv/series/women-lie-better-lv,serial-1024464/women-lie-better-lv,episode-1038762',
475 'only_matching': True,
477 'url': 'https://play.tv3.ee/series/_,serial-2654462/_,episode-2654474',
478 'only_matching': True,
480 'url': 'https://tv3play.skaties.lv/clips/tv3-zinas-valsti-lidz-15novembrim-bus-majsede,clip-3464509',
481 'only_matching': True,
484 def _real_extract(self
, url
):
485 country
, is_live
, video_id
= self
._match
_valid
_url
(url
).groups()
487 api_path
= 'lives/programmes' if is_live
else 'vods'
488 data
= self
._download
_json
(
489 urljoin(url
, f
'/api/products/{api_path}/{video_id}?platform=BROWSER&lang={country.upper()}'),
492 video_type
= 'CATCHUP' if is_live
else 'MOVIE'
493 stream_id
= data
['programRecordingId'] if is_live
else video_id
494 stream
= self
._download
_json
(
495 urljoin(url
, f
'/api/products/{stream_id}/videos/playlist?videoType={video_type}&platform=BROWSER'), video_id
)
496 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(
497 stream
['sources']['HLS'][0]['src'], video_id
, 'mp4', 'm3u8_native', m3u8_id
='hls')
498 self
._sort
_formats
(formats
)
500 thumbnails
= set(traverse_obj(
501 data
, (('galary', 'images', 'artworks'), ..., ..., ('miniUrl', 'mainUrl')), expected_type
=url_or_none
))
505 'title': self
._resolve
_title
(data
),
506 'description': traverse_obj(data
, 'description', 'lead'),
507 'duration': int_or_none(data
.get('duration')),
508 'season': traverse_obj(data
, ('season', 'serial', 'title')),
509 'season_number': int_or_none(traverse_obj(data
, ('season', 'number'))),
510 'episode': data
.get('title'),
511 'episode_number': int_or_none(data
.get('episode')),
512 'release_year': int_or_none(traverse_obj(data
, ('season', 'serial', 'year'))),
513 'thumbnails': [{'url': url, 'ext': 'jpg'}
for url
in thumbnails
],
515 'subtitles': subtitles
,
519 def _resolve_title(data
):
520 return try_get(data
, lambda x
: (
521 f
'{data["season"]["serial"]["title"]} ({data["season"]["serial"]["year"]}) | '
522 f
'S{data["season"]["number"]:02d}E{data["episode"]:02d}: {data["title"]}'
523 )) or data
.get('title')