1 from .common
import InfoExtractor
2 from .kaltura
import KalturaIE
12 class YleAreenaIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://areena\.yle\.fi/(?P<id>[\d-]+)'
14 _GEO_COUNTRIES
= ['FI']
17 'url': 'https://areena.yle.fi/1-4371942',
18 'md5': '932edda0ecf5dfd6423804182d32f8ac',
23 'description': 'md5:01071d7056ceec375f63960f90c35366',
24 'series': 'Modernit miehet',
27 'episode': 'Episode 2',
29 'thumbnail': 'http://cfvod.kaltura.com/p/1955031/sp/195503100/thumbnail/entry_id/0_a3tjk92c/version/100061',
30 'uploader_id': 'ovp@yle.fi',
33 'upload_date': '20181204',
34 'release_date': '20190106',
35 'timestamp': 1543916210,
36 'subtitles': {'fin': [{'url': r
're:^https?://', 'ext': 'srt'}]},
38 'webpage_url': 'https://areena.yle.fi/1-4371942',
42 'url': 'https://areena.yle.fi/1-2158940',
43 'md5': 'cecb603661004e36af8c5188b5212b12',
47 'title': 'Albi haluaa vessan',
48 'description': 'md5:15236d810c837bed861fae0e88663c33',
49 'series': 'Albi Lumiukko',
50 'thumbnail': 'http://cfvod.kaltura.com/p/1955031/sp/195503100/thumbnail/entry_id/1_l38iz9ur/version/100021',
51 'uploader_id': 'ovp@yle.fi',
54 'upload_date': '20211202',
55 'release_date': '20211215',
56 'timestamp': 1638448202,
59 'webpage_url': 'https://areena.yle.fi/1-2158940',
63 'url': 'https://areena.yle.fi/1-64829589',
67 'title': 'HKO & Mälkki & Tanner',
68 'description': 'md5:b4f1b1af2c6569b33f75179a86eea156',
69 'series': 'Helsingin kaupunginorkesterin konsertteja',
70 'thumbnail': r
're:^https?://.+\.jpg$',
71 'release_date': '20230120',
74 'skip_download': 'm3u8',
79 def _real_extract(self
, url
):
80 video_id
= self
._match
_id
(url
)
81 info
= self
._search
_json
_ld
(self
._download
_webpage
(url
, video_id
), video_id
, default
={})
82 video_data
= self
._download
_json
(
83 f
'https://player.api.yle.fi/v1/preview/{video_id}.json?app_id=player_static_prod&app_key=8930d72170e48303cf5f3867780d549b',
85 'origin': 'https://areena.yle.fi',
86 'referer': 'https://areena.yle.fi/',
87 'content-type': 'application/json',
90 # Example title: 'K1, J2: Pouchit | Modernit miehet'
91 season_number
, episode_number
, episode
, series
= self
._search
_regex
(
92 r
'K(?P<season_no>\d+),\s*J(?P<episode_no>\d+):?\s*\b(?P<episode>[^|]+)\s*|\s*(?P<series>.+)',
93 info
.get('title') or '', 'episode metadata', group
=('season_no', 'episode_no', 'episode', 'series'),
94 default
=(None, None, None, None))
95 description
= traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'description', 'fin'), expected_type
=str)
98 for sub
in traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'subtitles', ...)):
99 if url_or_none(sub
.get('uri')):
100 subtitles
.setdefault(sub
.get('language') or 'und', []).append({
103 'name': sub
.get('kind'),
106 kaltura_id
= traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'kaltura', 'id'), expected_type
=str)
109 '_type': 'url_transparent',
110 'url': smuggle_url(f
'kaltura:1955031:{kaltura_id}', {'source_url': url
}),
111 'ie_key': KalturaIE
.ie_key(),
114 formats
, subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(
115 video_data
['data']['ongoing_ondemand']['manifest_url'], video_id
, 'mp4', m3u8_id
='hls')
116 self
._merge
_subtitles
(subs
, target
=subtitles
)
124 'title': (traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'title', 'fin'), expected_type
=str)
125 or episode
or info
.get('title')),
126 'description': description
,
127 'series': (traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'series', 'title', 'fin'), expected_type
=str)
129 'season_number': (int_or_none(self
._search
_regex
(r
'Kausi (\d+)', description
, 'season number', default
=None))
130 or int_or_none(season_number
)),
131 'episode_number': (traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'episode_number'), expected_type
=int_or_none
)
132 or int_or_none(episode_number
)),
133 'thumbnails': traverse_obj(info
, ('thumbnails', ..., {'url': 'url'})),
134 'age_limit': traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'content_rating', 'age_restriction'), expected_type
=int_or_none
),
135 'subtitles': subtitles
or None,
136 'release_date': unified_strdate(traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'start_time'), expected_type
=str)),