3 from .common
import InfoExtractor
4 from ..networking
.exceptions
import HTTPError
17 class RozhlasIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?:www\.)?prehravac\.rozhlas\.cz/audio/(?P<id>[0-9]+)'
20 'url': 'http://prehravac.rozhlas.cz/audio/3421320',
21 'md5': '504c902dbc9e9a1fd50326eccf02a7e2',
25 'title': 'Echo Pavla Klusáka (30.06.2015 21:00)',
26 'description': 'Osmdesátiny Terryho Rileyho jsou skvělou příležitostí proletět se elektronickými i akustickými díly zakladatatele minimalismu, který je aktivní už přes padesát let',
29 'url': 'http://prehravac.rozhlas.cz/audio/3421320/embed',
30 'only_matching': True,
33 def _real_extract(self
, url
):
34 audio_id
= self
._match
_id
(url
)
36 webpage
= self
._download
_webpage
(
37 f
'http://prehravac.rozhlas.cz/audio/{audio_id}', audio_id
)
39 title
= self
._html
_search
_regex
(
40 r
'<h3>(.+?)</h3>\s*<p[^>]*>.*?</p>\s*<div[^>]+id=["\']player
-track
',
41 webpage, 'title
', default=None) or remove_start(
42 self._og_search_title(webpage), 'Radio Wave
- ')
43 description = self._html_search_regex(
44 r'<p
[^
>]+title
=(["\'])(?P<url>(?:(?!\1).)+)\1[^>]*>.*?</p>\s*<div[^>]+id=["\']player
-track
',
45 webpage, 'description
', fatal=False, group='url
')
46 duration = int_or_none(self._search_regex(
47 r'data
-duration
=["\'](\d+)', webpage, 'duration', default=None))
51 'url': f'http://media.rozhlas.cz/_audio/{audio_id}.mp3',
53 'description': description,
59 class RozhlasBaseIE(InfoExtractor):
60 def _extract_formats(self, entry, audio_id):
62 for audio in traverse_obj(entry, ('audioLinks', lambda _, v: url_or_none(v['url']))):
63 ext = audio.get('variant')
64 for retry in self.RetryManager():
66 self._sleep(1, audio_id)
69 formats.extend(self._extract_mpd_formats(
70 audio['url'], audio_id, mpd_id=ext))
72 formats.extend(self._extract_m3u8_formats(
73 audio['url'], audio_id, 'm4a', m3u8_id=ext))
79 'abr': int_or_none(audio.get('bitrate')),
83 except ExtractorError as e:
84 if isinstance(e.cause, HTTPError) and e.cause.status == 429:
87 self.report_warning(e.msg)
92 class RozhlasVltavaIE(RozhlasBaseIE):
93 _VALID_URL = r'https?://(?:\w+\.rozhlas|english\.radio)\.cz/[\w-]+-(?P<id>\d+)'
95 'url': 'https://wave.rozhlas.cz/papej-masicko-porcujeme-a-bilancujeme-filmy-a-serialy-ktere-letos-zabily-8891337',
96 'md5': 'ba2fdbc1242fc16771c7695d271ec355',
99 'title': 'md5:21f99739d04ab49d8c189ec711eef4ec',
103 'md5': 'ba2fdbc1242fc16771c7695d271ec355',
107 'title': 'Papej masíčko! Porcujeme a bilancujeme filmy a seriály, které to letos zabily',
108 'description': 'md5:1c6d29fb9564e1f17fc1bb83ae7da0bc',
110 'artist': 'Aleš Stuchlý',
111 'channel_id': 'radio-wave',
115 'url': 'https://wave.rozhlas.cz/poslechnete-si-neklid-podcastovy-thriller-o-vine-strachu-a-vztahu-ktery-zasel-8554744',
118 'title': 'Poslechněte si Neklid. Podcastový thriller o vině, strachu a vztahu, který zašel příliš daleko',
122 'md5': '93d4109cf8f40523699ae9c1d4600bdd',
126 'title': 'Neklid #1',
127 'description': '1. díl: Neklid: 1. díl',
129 'artist': 'Josef Kokta',
130 'channel_id': 'radio-wave',
131 'chapter': 'Neklid #1',
135 'md5': 'e9763235be4a6dcf94bc8a5bac1ca126',
139 'title': 'Neklid #2',
140 'description': '2. díl: Neklid: 2. díl',
142 'artist': 'Josef Kokta',
143 'channel_id': 'radio-wave',
144 'chapter': 'Neklid #2',
148 'md5': '00b642ea94b78cc949ac84da09f87895',
152 'title': 'Neklid #3',
153 'description': '3. díl: Neklid: 3. díl',
155 'artist': 'Josef Kokta',
156 'channel_id': 'radio-wave',
157 'chapter': 'Neklid #3',
161 'md5': 'faef97b1b49da7df874740f118c19dea',
165 'title': 'Neklid #4',
166 'description': '4. díl: Neklid: 4. díl',
168 'artist': 'Josef Kokta',
169 'channel_id': 'radio-wave',
170 'chapter': 'Neklid #4',
174 'md5': '6e729fa39b647325b868d419c76f3efa',
178 'title': 'Neklid #5',
179 'description': '5. díl: Neklid: 5. díl',
181 'artist': 'Josef Kokta',
182 'channel_id': 'radio-wave',
183 'chapter': 'Neklid #5',
188 'url': 'https://dvojka.rozhlas.cz/karel-siktanc-cerny-jezdec-bily-kun-napinava-pohadka-o-tajemnem-prizraku-8946969',
191 'title': 'Karel Šiktanc: Černý jezdec, bílý kůň. Napínavá pohádka o tajemném přízraku',
198 'title': 'Karel Šiktanc: Černý jezdec, bílý kůň. Napínavá pohádka o tajemném přízraku',
199 'description': 'Karel Šiktanc: Černý jezdec, bílý kůň',
201 'artist': 'Tvůrčí skupina Drama a literatura',
202 'channel_id': 'dvojka',
205 'params': {'skip_download': 'dash'},
208 def _extract_video(self, entry):
209 audio_id = entry['meta']['ga']['contentId']
210 chapter_number = traverse_obj(entry, ('meta', 'ga', 'contentSerialPart', {int_or_none}))
214 'chapter': traverse_obj(entry, ('meta', 'ga', 'contentNameShort')) if chapter_number else None,
215 'chapter_number': chapter_number,
216 'formats': self._extract_formats(entry, audio_id),
217 **traverse_obj(entry, {
218 'title': ('meta', 'ga', 'contentName'),
219 'description': 'title',
220 'duration': ('duration', {int_or_none}),
221 'artist': ('meta', 'ga', 'contentAuthor'),
222 'channel_id': ('meta', 'ga', 'contentCreator'),
226 def _real_extract(self, url):
227 video_id = self._match_id(url)
228 webpage = self._download_webpage(url, video_id)
230 # FIXME: Use get_element_text_and_html_by_tag when it accepts less strict html
231 data = self._parse_json(extract_attributes(self._search_regex(
232 r'(<div class="mujRozhlasPlayer
" data-player=\'[^\']+\'>)',
233 webpage, 'player'))['data-player'], video_id)['data']
237 'id': str_or_none(data.get('embedId')) or video_id,
238 'title': traverse_obj(data, ('series', 'title')),
239 'entries': map(self._extract_video, data['playlist']),
243 class MujRozhlasIE(RozhlasBaseIE):
244 _VALID_URL = r'https?://(?:www\.)?mujrozhlas\.cz/(?:[^/]+/)*(?P<id>[^/?#&]+)'
246 # single episode extraction
247 'url': 'https://www.mujrozhlas.cz/vykopavky/ach-jo-zase-teleci-rizek-je-mnohem-min-cesky-nez-jsme-si-mysleli',
248 'md5': '6f8fd68663e64936623e67c152a669e0',
252 'title': 'Ach jo, zase to telecí! Řízek je mnohem míň český, než jsme si mysleli',
253 'description': 'md5:db7141e9caaedc9041ec7cefb9a62908',
254 'timestamp': 1684915200,
255 'modified_timestamp': 1687550432,
256 'series': 'Vykopávky',
257 'thumbnail': 'https://portal.rozhlas.cz/sites/default/files/images/84377046610af6ddc54d910b1dd7a22b.jpg',
258 'channel_id': 'radio-wave',
259 'upload_date': '20230524',
260 'modified_date': '20230623',
264 'url': 'https://www.mujrozhlas.cz/radiokniha/jaroslava-janackova-pribeh-tajemneho-psani-o-pramenech-genezi-babicky',
265 'playlist_mincount': 7,
267 'id': 'bb2b5f4e-ffb4-35a6-a34a-046aa62d6f6b',
268 'title': 'Jaroslava Janáčková: Příběh tajemného psaní. O pramenech a genezi Babičky',
269 'description': 'md5:7434d8fac39ac9fee6df098e11dfb1be',
273 'url': 'https://www.mujrozhlas.cz/nespavci',
274 'playlist_mincount': 14,
276 'id': '09db9b37-d0f4-368c-986a-d3439f741f08',
278 'description': 'md5:c430adcbf9e2b9eac88b745881e814dc',
282 'url': 'https://www.mujrozhlas.cz/povidka/gustavo-adolfo-becquer-hora-duchu',
286 'title': 'Gustavo Adolfo Bécquer: Hora duchů',
287 'description': 'md5:343a15257b376c276e210b78e900ffea',
288 'chapter': 'Hora duchů a Polibek – dva tajemné příběhy Gustava Adolfa Bécquera',
289 'thumbnail': 'https://portal.rozhlas.cz/sites/default/files/images/2adfe1387fb140634be725c1ccf26214.jpg',
290 'timestamp': 1708173000,
291 'episode': 'Episode 1',
294 'modified_date': '20240217',
295 'upload_date': '20240217',
296 'modified_timestamp': 1708173198,
297 'channel_id': 'vltava',
299 'params': {'skip_download': 'dash'},
302 def _call_api(self, path, item_id, msg='API JSON'):
303 return self._download_json(
304 f'https://api.mujrozhlas.cz/{path}/{item_id}', item_id,
305 note=f'Downloading {msg}', errnote=f'Failed to download {msg}')['data']
307 def _extract_audio_entry(self, entry):
308 audio_id = entry['meta']['ga']['contentId']
312 'formats': self._extract_formats(entry['attributes'], audio_id),
313 **traverse_obj(entry, {
314 'title': ('attributes', 'title'),
315 'description': ('attributes', 'description'),
316 'episode_number': ('attributes', 'part'),
317 'series': ('attributes', 'mirroredShow', 'title'),
318 'chapter': ('attributes', 'mirroredSerial', 'title'),
319 'artist': ('meta', 'ga', 'contentAuthor'),
320 'channel_id': ('meta', 'ga', 'contentCreator'),
321 'timestamp': ('attributes', 'since', {unified_timestamp}),
322 'modified_timestamp': ('attributes', 'updated', {unified_timestamp}),
323 'thumbnail': ('attributes', 'asset', 'url', {url_or_none}),
327 def _entries(self, api_url, playlist_id):
328 for page in itertools.count(1):
329 episodes = self._download_json(
330 api_url, playlist_id, note=f'Downloading episodes page {page}',
331 errnote=f'Failed to download episodes page {page}', fatal=False)
332 for episode in traverse_obj(episodes, ('data', lambda _, v: v['meta']['ga']['contentId'])):
333 yield self._extract_audio_entry(episode)
334 api_url = traverse_obj(episodes, ('links', 'next', {url_or_none}))
338 def _real_extract(self, url):
339 display_id = self._match_id(url)
340 webpage = self._download_webpage(url, display_id)
341 info = self._search_json(r'\bvar\s+dl\s*=', webpage, 'info json', display_id)
343 entity = info['siteEntityBundle']
345 if entity in ('episode', 'serialPart'):
346 return self._extract_audio_entry(self._call_api(
347 'episodes', info['contentId'], 'episode info API JSON'))
349 elif entity in ('show', 'serial'):
350 playlist_id = info['contentShow'].split(':')[0] if entity == 'show' else info['contentId']
351 data = self._call_api(f'{entity}s', playlist_id, f'{entity} playlist JSON')
352 api_url = data['relationships']['episodes']['links']['related']
353 return self.playlist_result(
354 self._entries(api_url, playlist_id), playlist_id,
355 **traverse_obj(data, ('attributes', {
357 'description': 'description',
361 # `entity == 'person'` not implemented yet by API, ref:
362 # https://api.mujrozhlas.cz/persons/8367e456-2a57-379a-91bb-e699619bea49/participation
363 raise ExtractorError(f'Unsupported entity type "{entity}
"')