+ # both episodes and articles, PR3
+ 'url': 'https://trojka.polskieradio.pl/audycja/8906',
+ 'info_dict': {
+ 'id': '8906',
+ 'title': 'Trójka budzi',
+ 'thumbnail': r're:https://static\.prsa\.pl/images/.+',
+ },
+ 'playlist_mincount': 722,
+ }]
+
+ def _call_lp3(self, path, query, video_id, note):
+ return self._download_json(
+ f'https://lp3test.polskieradio.pl/{path}', video_id, note,
+ query=query, headers={'x-api-key': '9bf6c5a2-a7d0-4980-9ed7-a3f7291f2a81'})
+
+ def _entries(self, playlist_id, has_episodes, has_articles):
+ for i in itertools.count(1) if has_episodes else []:
+ page = self._call_lp3(
+ 'AudioArticle/GetListByCategoryId', {
+ 'categoryId': playlist_id,
+ 'PageSize': 10,
+ 'skip': i,
+ 'format': 400,
+ }, playlist_id, f'Downloading episode list page {i}')
+ if not traverse_obj(page, 'data'):
+ break
+ for episode in page['data']:
+ yield {
+ 'id': str(episode['id']),
+ 'url': episode['file'],
+ 'title': episode.get('title'),
+ 'duration': int_or_none(episode.get('duration')),
+ 'timestamp': parse_iso8601(episode.get('datePublic')),
+ }
+
+ for i in itertools.count(1) if has_articles else []:
+ page = self._call_lp3(
+ 'Article/GetListByCategoryId', {
+ 'categoryId': playlist_id,
+ 'PageSize': 9,
+ 'skip': i,
+ 'format': 400,
+ }, playlist_id, f'Downloading article list page {i}')
+ if not traverse_obj(page, 'data'):
+ break
+ for article in page['data']:
+ yield {
+ '_type': 'url_transparent',
+ 'ie_key': PolskieRadioIE.ie_key(),
+ 'id': str(article['id']),
+ 'url': article['url'],
+ 'title': article.get('shortTitle'),
+ 'description': traverse_obj(article, ('description', 'lead')),
+ 'timestamp': parse_iso8601(article.get('datePublic')),
+ }
+
+ def _real_extract(self, url):
+ playlist_id = self._match_id(url)
+
+ page_props = traverse_obj(
+ self._search_nextjs_data(self._download_webpage(url, playlist_id), playlist_id),
+ ('props', 'pageProps', ('data', None)), get_all=False)
+
+ has_episodes = bool(traverse_obj(page_props, 'episodes', 'audios'))
+ has_articles = bool(traverse_obj(page_props, 'articles'))
+
+ return self.playlist_result(
+ self._entries(playlist_id, has_episodes, has_articles), playlist_id,
+ title=traverse_obj(page_props, ('details', 'name')),
+ description=traverse_obj(page_props, ('details', 'description', 'lead')),
+ thumbnail=traverse_obj(page_props, ('details', 'photo')))
+
+
+class PolskieRadioCategoryIE(InfoExtractor):
+ # legacy sites
+ IE_NAME = 'polskieradio:category'
+ _VALID_URL = r'https?://(?:www\.)?polskieradio\.pl/\d+(?:,[^/]+)?/(?P<id>\d+)'
+ _TESTS = [{