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