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-]+)'
16 'url': 'https://areena.yle.fi/1-4371942',
17 'md5': '932edda0ecf5dfd6423804182d32f8ac',
22 'description': 'md5:d487309c3abbe5650265bbd1742d2f82',
23 'series': 'Modernit miehet',
26 'episode': 'Episode 2',
28 'thumbnail': 'http://cfvod.kaltura.com/p/1955031/sp/195503100/thumbnail/entry_id/0_a3tjk92c/version/100061',
29 'uploader_id': 'ovp@yle.fi',
32 'upload_date': '20181204',
33 'release_date': '20190106',
34 'timestamp': 1543916210,
35 'subtitles': {'fin': [{'url': r're:^https?://', 'ext': 'srt'}
]},
37 'webpage_url': 'https://areena.yle.fi/1-4371942'
41 'url': 'https://areena.yle.fi/1-2158940',
42 'md5': 'cecb603661004e36af8c5188b5212b12',
46 'title': 'Albi haluaa vessan',
47 'description': 'md5:15236d810c837bed861fae0e88663c33',
48 'series': 'Albi Lumiukko',
50 'season_number': None,
52 'episode_number': None,
53 'thumbnail': 'http://cfvod.kaltura.com/p/1955031/sp/195503100/thumbnail/entry_id/1_l38iz9ur/version/100021',
54 'uploader_id': 'ovp@yle.fi',
57 'upload_date': '20211202',
58 'release_date': '20211215',
59 'timestamp': 1638448202,
62 'webpage_url': 'https://areena.yle.fi/1-2158940'
67 def _real_extract(self
, url
):
68 video_id
= self
._match
_id
(url
)
69 info
= self
._search
_json
_ld
(self
._download
_webpage
(url
, video_id
), video_id
, default
={})
70 video_data
= self
._download
_json
(
71 f
'https://player.api.yle.fi/v1/preview/{video_id}.json?app_id=player_static_prod&app_key=8930d72170e48303cf5f3867780d549b',
73 'origin': 'https://areena.yle.fi',
74 'referer': 'https://areena.yle.fi/',
75 'content-type': 'application/json'
78 # Example title: 'K1, J2: Pouchit | Modernit miehet'
79 series
, season_number
, episode_number
, episode
= self
._search
_regex
(
80 r
'K(?P<season_no>[\d]+),\s*J(?P<episode_no>[\d]+):?\s*\b(?P<episode>[^|]+)\s*|\s*(?P<series>.+)',
81 info
.get('title') or '', 'episode metadata', group
=('season_no', 'episode_no', 'episode', 'series'),
82 default
=(None, None, None, None))
83 description
= traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'description', 'fin'), expected_type
=str)
86 for sub
in traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'subtitles', ...)):
87 if url_or_none(sub
.get('uri')):
88 subtitles
.setdefault(sub
.get('language') or 'und', []).append({
91 'name': sub
.get('kind'),
95 '_type': 'url_transparent',
97 f
'kaltura:1955031:{video_data["data"]["ongoing_ondemand"]["kaltura"]["id"]}',
99 'ie_key': KalturaIE
.ie_key(),
100 'title': (traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'title', 'fin'), expected_type
=str)
101 or episode
or info
.get('title')),
102 'description': description
,
103 'series': (traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'series', 'title', 'fin'), expected_type
=str)
105 'season_number': (int_or_none(self
._search
_regex
(r
'Kausi (\d+)', description
, 'season number', default
=None))
106 or int_or_none(season_number
)),
107 'episode_number': (traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'episode_number'), expected_type
=int_or_none
)
108 or int_or_none(episode_number
)),
109 'thumbnails': traverse_obj(info
, ('thumbnails', ..., {'url': 'url'}
)),
110 'age_limit': traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'content_rating', 'age_restriction'), expected_type
=int_or_none
),
111 'subtitles': subtitles
,
112 'release_date': unified_strdate(traverse_obj(video_data
, ('data', 'ongoing_ondemand', 'start_time'), expected_type
=str)),