[ie/dropbox] Fix password-protected video extraction (#11636)
[yt-dlp3.git] / yt_dlp / extractor / iltalehti.py
blob37aa47165ed2e0af3b862664a3565a6bdef6fd58
1 from .common import InfoExtractor
2 from ..utils import js_to_json, traverse_obj
5 class IltalehtiIE(InfoExtractor):
6 _VALID_URL = r'https?://(?:www\.)?iltalehti\.fi/[^/?#]+/a/(?P<id>[^/?#])'
7 _TESTS = [
8 # jwplatform embed main_media
10 'url': 'https://www.iltalehti.fi/ulkomaat/a/9fbd067f-94e4-46cd-8748-9d958eb4dae2',
11 'md5': 'af12d42c539f1f49f0b62d231fe72dcd',
12 'info_dict': {
13 'id': 'gYjjaf1L',
14 'ext': 'mp4',
15 'title': 'Sensuroimaton Päivärinta, jakso 227: Vieraana Suomen Venäjän ex-suurlähettiläs René Nyberg ja Kenraalimajuri evp Pekka Toveri',
16 'description': '',
17 'upload_date': '20220928',
18 'timestamp': 1664360878,
19 'duration': 2089,
20 'thumbnail': r're:^https?://.*\.jpg',
23 # jwplatform embed body
25 'url': 'https://www.iltalehti.fi/politiikka/a/1ce49d85-1670-428b-8db8-d2479b9950a4',
26 'md5': '9e50334b8f8330ce8828b567a82a3c65',
27 'info_dict': {
28 'id': '18R6zkLi',
29 'ext': 'mp4',
30 'title': 'Pekka Toverin arvio: Näin Nord Stream -kaasuputken räjäyttäminen on saatettu toteuttaa',
31 'description': 'md5:3d1302c9e17e7ffd564143ff58f8de35',
32 'upload_date': '20220929',
33 'timestamp': 1664435867,
34 'duration': 165.0,
35 'thumbnail': r're:^https?://.*\.jpg',
40 def _real_extract(self, url):
41 article_id = self._match_id(url)
42 webpage = self._download_webpage(url, article_id)
43 info = self._search_json(
44 r'<script>\s*window.App\s*=', webpage, 'json', article_id,
45 transform_source=js_to_json)
46 props = traverse_obj(info, (
47 'state', 'articles', ..., 'items', (('main_media', 'properties'), ('body', ..., 'properties'))))
48 video_ids = traverse_obj(props, (lambda _, v: v['provider'] == 'jwplayer', 'id'))
49 return self.playlist_from_matches(
50 video_ids, article_id, ie='JWPlatform', getter=lambda video_id: f'jwplatform:{video_id}',
51 title=traverse_obj(info, ('state', 'articles', ..., 'items', 'canonical_title'), get_all=False))