[ie/soundcloud] Various fixes (#11820)
[yt-dlp.git] / yt_dlp / extractor / radiozet.py
blobe91b3b277947642d265570f22f83fa0ffd48980d
1 from .common import InfoExtractor
2 from ..utils import (
3 strip_or_none,
4 traverse_obj,
8 class RadioZetPodcastIE(InfoExtractor):
9 _VALID_URL = r'https?://player\.radiozet\.pl\/Podcasty/.*?/(?P<id>.+)'
10 _TEST = {
11 'url': 'https://player.radiozet.pl/Podcasty/Nie-Ma-Za-Co/O-przedmiotach-szkolnych-ktore-przydaja-sie-w-zyciu',
12 'md5': 'e03665c316b4fbc5f6a8f232948bbba3',
13 'info_dict': {
14 'id': '42154',
15 'display_id': 'O-przedmiotach-szkolnych-ktore-przydaja-sie-w-zyciu',
16 'title': 'O przedmiotach szkolnych, które przydają się w życiu',
17 'description': 'md5:fa72bed49da334b09e5b2f79851f185c',
18 'release_timestamp': 1592985480,
19 'ext': 'mp3',
20 'thumbnail': r're:^https?://.*\.png$',
21 'duration': 83,
22 'series': 'Nie Ma Za Co',
23 'creator': 'Katarzyna Pakosińska',
27 def _call_api(self, podcast_id, display_id):
28 return self._download_json(
29 f'https://player.radiozet.pl/api/podcasts/getPodcast/(node)/{podcast_id}/(station)/radiozet',
30 display_id)
32 def _real_extract(self, url):
33 display_id = self._match_id(url)
34 webpage = self._download_webpage(url, display_id)
35 podcast_id = self._html_search_regex(r'<div.*?\sid="player".*?\sdata-id=[\'"]([^\'"]+)[\'"]',
36 webpage, 'podcast id')
37 data = self._call_api(podcast_id, display_id)['data'][0]
39 return {
40 'id': podcast_id,
41 'display_id': display_id,
42 'title': strip_or_none(data.get('title')),
43 'description': strip_or_none(traverse_obj(data, ('program', 'desc'))),
44 'release_timestamp': data.get('published_date'),
45 'url': traverse_obj(data, ('player', 'stream')),
46 'thumbnail': traverse_obj(data, ('program', 'image', 'original')),
47 'duration': traverse_obj(data, ('player', 'duration')),
48 'series': strip_or_none(traverse_obj(data, ('program', 'title'))),
49 'creator': strip_or_none(traverse_obj(data, ('presenter', 0, 'title'))),