2 from .common
import InfoExtractor
10 from ..utils
.traversal
import traverse_obj
13 class IlPostIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?#]+)'
16 'url': 'https://www.ilpost.it/episodes/1-avis-akvasas-ka/',
17 'md5': '43649f002d85e1c2f319bb478d479c40',
21 'display_id': '1-avis-akvasas-ka',
22 'title': '1. Avis akvasas ka',
23 'url': 'https://www.ilpost.it/wp-content/uploads/2023/12/28/1703781217-l-invasione-pt1-v6.mp3',
24 'timestamp': 1703835014,
25 'upload_date': '20231229',
27 'availability': 'public',
28 'series_id': '235598',
33 def _real_extract(self
, url
):
34 display_id
= self
._match
_id
(url
)
35 webpage
= self
._download
_webpage
(url
, display_id
)
37 endpoint_metadata
= self
._search
_json
(
38 r
'var\s+ilpostpodcast\s*=', webpage
, 'metadata', display_id
)
39 episode_id
= endpoint_metadata
['post_id']
40 podcast_id
= endpoint_metadata
['podcast_id']
41 podcast_metadata
= self
._download
_json
(
42 endpoint_metadata
['ajax_url'], display_id
, data
=urlencode_postdata({
43 'action': 'checkpodcast',
44 'cookie': endpoint_metadata
['cookie'],
45 'post_id': episode_id
,
46 'podcast_id': podcast_id
,
49 episode
= traverse_obj(podcast_metadata
, (
50 'data', 'postcastList', lambda _
, v
: str(v
['id']) == episode_id
, {dict}
), get_all
=False)
52 raise ExtractorError('Episode could not be extracted')
56 'display_id': display_id
,
57 'series_id': podcast_id
,
59 **traverse_obj(episode
, {
60 'title': ('title', {str}
),
61 'description': ('description', {str}
),
62 'url': ('podcast_raw_url', {url_or_none}
),
63 'thumbnail': ('image', {url_or_none}
),
64 'timestamp': ('timestamp', {int_or_none}
),
65 'duration': ('milliseconds', {float_or_none(scale
=1000)}),
66 'availability': ('free', {lambda v
: 'public' if v
else 'subscriber_only'}),