1 from .common
import InfoExtractor
10 class IHeartRadioBaseIE(InfoExtractor
):
11 def _call_api(self
, path
, video_id
, fatal
=True, query
=None):
12 return self
._download
_json
(
13 'https://api.iheart.com/api/v3/podcast/' + path
,
14 video_id
, fatal
=fatal
, query
=query
)
16 def _extract_episode(self
, episode
):
18 'thumbnail': episode
.get('imageUrl'),
19 'description': clean_html(episode
.get('description')),
20 'timestamp': int_or_none(episode
.get('startDate'), 1000),
21 'duration': int_or_none(episode
.get('duration')),
25 class IHeartRadioIE(IHeartRadioBaseIE
):
26 IE_NAME
= 'iheartradio'
27 _VALID_URL
= r
'(?:https?://(?:www\.)?iheart\.com/podcast/[^/]+/episode/(?P<display_id>[^/?&#]+)-|iheartradio:)(?P<id>\d+)'
29 'url': 'https://www.iheart.com/podcast/105-behind-the-bastards-29236323/episode/part-one-alexander-lukashenko-the-dictator-70346499/?embed=true',
30 'md5': 'c8609c92c8688dcb69d8541042b8abca',
34 'title': 'Part One: Alexander Lukashenko: The Dictator of Belarus',
35 'description': 'md5:96cc7297b3a5a9ebae28643801c96fae',
36 'timestamp': 1597741200,
37 'upload_date': '20200818',
41 def _real_extract(self
, url
):
42 episode_id
= self
._match
_id
(url
)
43 episode
= self
._call
_api
(
44 'episodes/' + episode_id
, episode_id
)['episode']
45 info
= self
._extract
_episode
(episode
)
48 'title': episode
['title'],
49 'url': clean_podcast_url(episode
['mediaUrl']),
54 class IHeartRadioPodcastIE(IHeartRadioBaseIE
):
55 IE_NAME
= 'iheartradio:podcast'
56 _VALID_URL
= r
'https?://(?:www\.)?iheart(?:podcastnetwork)?\.com/podcast/[^/?&#]+-(?P<id>\d+)/?(?:[?#&]|$)'
58 'url': 'https://www.iheart.com/podcast/1119-it-could-happen-here-30717896/',
61 'title': 'It Could Happen Here',
62 'description': 'md5:5842117412a967eb0b01f8088eb663e2',
64 'playlist_mincount': 11,
66 'url': 'https://www.iheartpodcastnetwork.com/podcast/105-stuff-you-should-know-26940277',
67 'only_matching': True,
70 def _real_extract(self
, url
):
71 podcast_id
= self
._match
_id
(url
)
72 path
= 'podcasts/' + podcast_id
73 episodes
= self
._call
_api
(
74 path
+ '/episodes', podcast_id
, query
={'limit': 1000000000})['data']
77 for episode
in episodes
:
78 episode_id
= str_or_none(episode
.get('id'))
81 info
= self
._extract
_episode
(episode
)
85 'title': episode
.get('title'),
86 'url': 'iheartradio:' + episode_id
,
87 'ie_key': IHeartRadioIE
.ie_key(),
91 podcast
= self
._call
_api
(path
, podcast_id
, False) or {}
93 return self
.playlist_result(
94 entries
, podcast_id
, podcast
.get('title'), podcast
.get('description'))