[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / philharmoniedeparis.py
blob310ea0f742d7823c695c5158888b062c3c457b33
1 from .common import InfoExtractor
2 from ..utils import try_get
5 class PhilharmonieDeParisIE(InfoExtractor):
6 IE_DESC = 'Philharmonie de Paris'
7 _VALID_URL = r'''(?x)
8 https?://
9 (?:
10 live\.philharmoniedeparis\.fr/(?:[Cc]oncert/|embed(?:app)?/|misc/Playlist\.ashx\?id=)|
11 pad\.philharmoniedeparis\.fr/(?:doc/CIMU/|player\.aspx\?id=)|
12 philharmoniedeparis\.fr/fr/live/concert/|
13 otoplayer\.philharmoniedeparis\.fr/fr/embed/
15 (?P<id>\d+)
16 '''
17 _TESTS = [{
18 'url': 'https://philharmoniedeparis.fr/fr/live/concert/1129666-danses-symphoniques',
19 'md5': '24bdb7e86c200c107680e1f7770330ae',
20 'info_dict': {
21 'id': '1129666',
22 'ext': 'mp4',
23 'title': 'Danses symphoniques. Orchestre symphonique Divertimento - Zahia Ziouani. Bizet, de Falla, Stravinski, Moussorgski, Saint-Saëns',
25 }, {
26 'url': 'https://philharmoniedeparis.fr/fr/live/concert/1032066-akademie-fur-alte-musik-berlin-rias-kammerchor-rene-jacobs-passion-selon-saint-jean-de-johann',
27 'info_dict': {
28 'id': '1032066',
29 'title': 'Akademie für alte Musik Berlin, Rias Kammerchor, René Jacobs : Passion selon saint Jean de Johann Sebastian Bach',
31 'playlist_mincount': 2,
32 }, {
33 'url': 'https://philharmoniedeparis.fr/fr/live/concert/1030324-orchestre-philharmonique-de-radio-france-myung-whun-chung-renaud-capucon-pascal-dusapin-johannes',
34 'only_matching': True,
35 }, {
36 'url': 'http://live.philharmoniedeparis.fr/misc/Playlist.ashx?id=1030324&track=&lang=fr',
37 'only_matching': True,
38 }, {
39 'url': 'https://live.philharmoniedeparis.fr/embedapp/1098406/berlioz-fantastique-lelio-les-siecles-national-youth-choir-of.html?lang=fr-FR',
40 'only_matching': True,
41 }, {
42 'url': 'https://otoplayer.philharmoniedeparis.fr/fr/embed/1098406?lang=fr-FR',
43 'only_matching': True,
46 def _real_extract(self, url):
47 video_id = self._match_id(url)
49 config = self._download_json(
50 f'https://otoplayer.philharmoniedeparis.fr/fr/config/{video_id}.json', video_id, query={
51 'id': video_id,
52 'lang': 'fr-FR',
55 def extract_entry(source):
56 if not isinstance(source, dict):
57 return
58 title = source.get('title')
59 if not title:
60 return
61 files = source.get('files')
62 if not isinstance(files, dict):
63 return
64 format_urls = set()
65 formats = []
66 for format_id in ('mobile', 'desktop'):
67 format_url = try_get(
68 files, lambda x: x[format_id]['file'], str)
69 if not format_url or format_url in format_urls:
70 continue
71 format_urls.add(format_url)
72 formats.extend(self._extract_m3u8_formats(
73 format_url, video_id, 'mp4', entry_protocol='m3u8_native',
74 m3u8_id='hls', fatal=False))
75 if not formats and not self.get_param('ignore_no_formats'):
76 return
77 return {
78 'title': title,
79 'formats': formats,
80 'thumbnail': files.get('thumbnail'),
82 info = extract_entry(config)
83 if info:
84 info.update({
85 'id': video_id,
87 return info
88 entries = []
89 for num, chapter in enumerate(config['chapters'], start=1):
90 entry = extract_entry(chapter)
91 if entry is None:
92 continue
93 entry['id'] = f'{video_id}-{num}'
94 entries.append(entry)
96 return self.playlist_result(entries, video_id, config.get('title'))