mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-06-27 17:08:32 +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 ..utils import (
|
||||
clean_html,
|
||||
@ -11,8 +13,7 @@
|
||||
|
||||
class IlPostIE(InfoExtractor):
|
||||
_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/',
|
||||
'md5': '55d88cc23bcab991639ebcbf1b4c0aa1',
|
||||
'info_dict': {
|
||||
@ -47,14 +48,14 @@ class IlPostIE(InfoExtractor):
|
||||
'series_id': '235598',
|
||||
'thumbnail': 'https://www.ilpost.it/wp-content/uploads/2023/12/22/1703238848-copertina500x500.jpg',
|
||||
},
|
||||
},
|
||||
]
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
display_id = self._match_id(url)
|
||||
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 {
|
||||
'id': str(episode['id']),
|
||||
@ -74,8 +75,7 @@ def _real_extract(self, url):
|
||||
|
||||
class IlPostPodcastIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?ilpost\.it/podcasts/(?P<id>[^/?#]+)/?(?:[?#]|$)'
|
||||
_TESTS = [
|
||||
{
|
||||
_TESTS = [{
|
||||
'url': 'https://www.ilpost.it/podcasts/basaglia-e-i-suoi/',
|
||||
'info_dict': {
|
||||
'id': '239295',
|
||||
@ -90,18 +90,30 @@ class IlPostPodcastIE(InfoExtractor):
|
||||
'title': 'Morning',
|
||||
},
|
||||
'playlist_mincount': 20,
|
||||
},
|
||||
]
|
||||
}]
|
||||
|
||||
def _real_extract(self, 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'})
|
||||
data = self._download_json(f'https://api-prod.ilpost.it/podcast/v1/podcast/{display_id}', display_id, query={'hits': data['head']['data']['total']})
|
||||
max_hits = 10000 # found experimentally
|
||||
|
||||
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:
|
||||
podcast = traverse_obj(data, ('data', 0, 'parent'))
|
||||
|
||||
if data.get('data') is None:
|
||||
break
|
||||
|
||||
entries += [{
|
||||
'_type': 'url',
|
||||
'ie_key': IlPostIE.ie_key(),
|
||||
'url': episode['url'],
|
||||
@ -112,5 +124,4 @@ def _real_extract(self, url):
|
||||
}),
|
||||
} for episode in traverse_obj(data, ('data', lambda _, v: url_or_none(v['url'])))]
|
||||
|
||||
return self.playlist_result(entries,
|
||||
str(podcast['id']), clean_html(podcast.get('title')))
|
||||
return self.playlist_result(entries, str_or_none(podcast.get('id')), clean_html(podcast.get('title')))
|
||||
|
Loading…
Reference in New Issue
Block a user