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