mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-06-27 08:58:30 +00:00
[ie/IlPost] Fix extractor - merge review pt2
This commit is contained in:
parent
f736c9627f
commit
1b4110c8de
@ -1,3 +1,5 @@
|
|||||||
|
import itertools
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
@ -11,25 +13,24 @@
|
|||||||
|
|
||||||
class IlPostIE(InfoExtractor):
|
class IlPostIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?ilpost\.it/podcasts/[^/?#]+/(?P<id>[^/?#]+)'
|
_VALID_URL = r'https?://(?:www\.)?ilpost\.it/podcasts/[^/?#]+/(?P<id>[^/?#]+)'
|
||||||
_TESTS = [
|
_TESTS = [{
|
||||||
{
|
'url': 'https://www.ilpost.it/podcasts/timbuctu/ep-323-lanno-record-della-pena-di-morte/',
|
||||||
'url': 'https://www.ilpost.it/podcasts/timbuctu/ep-323-lanno-record-della-pena-di-morte/',
|
'md5': '55d88cc23bcab991639ebcbf1b4c0aa1',
|
||||||
'md5': '55d88cc23bcab991639ebcbf1b4c0aa1',
|
'info_dict': {
|
||||||
'info_dict': {
|
'id': '3326553',
|
||||||
'id': '3326553',
|
'ext': 'mp3',
|
||||||
'ext': 'mp3',
|
'display_id': 'ep-323-lanno-record-della-pena-di-morte',
|
||||||
'display_id': 'ep-323-lanno-record-della-pena-di-morte',
|
'title': 'Ep. 323 – L’anno record della pena di morte',
|
||||||
'title': 'Ep. 323 – L’anno record della pena di morte',
|
'url': 'https://static-prod.cdnilpost.com/wp-content/uploads/2025/05/25/1748196012-timbuctu_250526_v1_-16lufs.mp3',
|
||||||
'url': 'https://static-prod.cdnilpost.com/wp-content/uploads/2025/05/25/1748196012-timbuctu_250526_v1_-16lufs.mp3',
|
'timestamp': 1748235641,
|
||||||
'timestamp': 1748235641,
|
'upload_date': '20250526',
|
||||||
'upload_date': '20250526',
|
'description': 'md5:331514a14779fab06e902160ec8c89ba',
|
||||||
'description': 'md5:331514a14779fab06e902160ec8c89ba',
|
'duration': 751,
|
||||||
'duration': 751,
|
'availability': 'public',
|
||||||
'availability': 'public',
|
'series_id': '233679',
|
||||||
'series_id': '233679',
|
'thumbnail': 'https://www.ilpost.it/wp-content/uploads/2023/05/19/1684536738-copertina500x500.jpg',
|
||||||
'thumbnail': 'https://www.ilpost.it/wp-content/uploads/2023/05/19/1684536738-copertina500x500.jpg',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'url': 'https://www.ilpost.it/podcasts/l-invasione/1-avis-akvasas-ka/',
|
'url': 'https://www.ilpost.it/podcasts/l-invasione/1-avis-akvasas-ka/',
|
||||||
'md5': '43649f002d85e1c2f319bb478d479c40',
|
'md5': '43649f002d85e1c2f319bb478d479c40',
|
||||||
@ -47,14 +48,14 @@ class IlPostIE(InfoExtractor):
|
|||||||
'series_id': '235598',
|
'series_id': '235598',
|
||||||
'thumbnail': 'https://www.ilpost.it/wp-content/uploads/2023/12/22/1703238848-copertina500x500.jpg',
|
'thumbnail': 'https://www.ilpost.it/wp-content/uploads/2023/12/22/1703238848-copertina500x500.jpg',
|
||||||
},
|
},
|
||||||
},
|
}]
|
||||||
]
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, display_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
|
|
||||||
episode = self._search_nextjs_data(webpage, display_id)['props']['pageProps']['data']['data']['episode']['data'][0]
|
episode = self._search_nextjs_data(
|
||||||
|
webpage, display_id)['props']['pageProps']['data']['data']['episode']['data'][0]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': str(episode['id']),
|
'id': str(episode['id']),
|
||||||
@ -74,15 +75,14 @@ def _real_extract(self, url):
|
|||||||
|
|
||||||
class IlPostPodcastIE(InfoExtractor):
|
class IlPostPodcastIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?ilpost\.it/podcasts/(?P<id>[^/?#]+)/?(?:[?#]|$)'
|
_VALID_URL = r'https?://(?:www\.)?ilpost\.it/podcasts/(?P<id>[^/?#]+)/?(?:[?#]|$)'
|
||||||
_TESTS = [
|
_TESTS = [{
|
||||||
{
|
'url': 'https://www.ilpost.it/podcasts/basaglia-e-i-suoi/',
|
||||||
'url': 'https://www.ilpost.it/podcasts/basaglia-e-i-suoi/',
|
'info_dict': {
|
||||||
'info_dict': {
|
'id': '239295',
|
||||||
'id': '239295',
|
'title': 'Basaglia e i suoi',
|
||||||
'title': 'Basaglia e i suoi',
|
|
||||||
},
|
|
||||||
'playlist_mincount': 5,
|
|
||||||
},
|
},
|
||||||
|
'playlist_mincount': 5,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'url': 'https://www.ilpost.it/podcasts/morning/',
|
'url': 'https://www.ilpost.it/podcasts/morning/',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -90,27 +90,38 @@ class IlPostPodcastIE(InfoExtractor):
|
|||||||
'title': 'Morning',
|
'title': 'Morning',
|
||||||
},
|
},
|
||||||
'playlist_mincount': 20,
|
'playlist_mincount': 20,
|
||||||
},
|
}]
|
||||||
]
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
|
entries = []
|
||||||
|
podcast = None
|
||||||
|
|
||||||
data = self._download_json(f'https://api-prod.ilpost.it/podcast/v1/podcast/{display_id}', display_id, query={'hits': '20'})
|
max_hits = 10000 # found experimentally
|
||||||
data = self._download_json(f'https://api-prod.ilpost.it/podcast/v1/podcast/{display_id}', display_id, query={'hits': data['head']['data']['total']})
|
|
||||||
|
|
||||||
podcast = data['data'][0]['parent']
|
for page in itertools.count(1):
|
||||||
|
data = self._download_json(
|
||||||
|
f'https://api-prod.ilpost.it/podcast/v1/podcast/{display_id}',
|
||||||
|
display_id,
|
||||||
|
query={'hits': max_hits, 'pg': page},
|
||||||
|
expected_status=500,
|
||||||
|
)
|
||||||
|
|
||||||
entries = [{
|
if podcast is None:
|
||||||
'_type': 'url',
|
podcast = traverse_obj(data, ('data', 0, 'parent'))
|
||||||
'ie_key': IlPostIE.ie_key(),
|
|
||||||
'url': episode['url'],
|
|
||||||
**traverse_obj(episode, {
|
|
||||||
'episode_id': ('id', {str_or_none}),
|
|
||||||
'title': ('title', {clean_html}),
|
|
||||||
'description': ('content_html', {clean_html}),
|
|
||||||
}),
|
|
||||||
} for episode in traverse_obj(data, ('data', lambda _, v: url_or_none(v['url'])))]
|
|
||||||
|
|
||||||
return self.playlist_result(entries,
|
if data.get('data') is None:
|
||||||
str(podcast['id']), clean_html(podcast.get('title')))
|
break
|
||||||
|
|
||||||
|
entries += [{
|
||||||
|
'_type': 'url',
|
||||||
|
'ie_key': IlPostIE.ie_key(),
|
||||||
|
'url': episode['url'],
|
||||||
|
**traverse_obj(episode, {
|
||||||
|
'episode_id': ('id', {str_or_none}),
|
||||||
|
'title': ('title', {clean_html}),
|
||||||
|
'description': ('content_html', {clean_html}),
|
||||||
|
}),
|
||||||
|
} for episode in traverse_obj(data, ('data', lambda _, v: url_or_none(v['url'])))]
|
||||||
|
|
||||||
|
return self.playlist_result(entries, str_or_none(podcast.get('id')), clean_html(podcast.get('title')))
|
||||||
|
Loading…
Reference in New Issue
Block a user