Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/polskieradio.py (Python)

Code before:
                        'categoryId': playlist_id,
                        'PageSize': 9,
                        'skip': i,
                        'format': 400,
                    }, playlist_id, f'Downloading article list (page #{i})')
                for article in page['data']:
                    yield {
                        '_type': 'url_transparent',
                        'id': str(article['id']),
                        'title': article['shortTitle'],
                        'url': article['url'],
                        'ie_key': PolskieRadioIE,
                        'description': traverse_obj(article, ('description', 'lead')),
                        'timestamp': parse_iso8601(article.get('datePublic')),
                    }
                not_empty = len(page['data']) > 0
                i += 1

    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'))
        if page_props.get('data'):
            page_props = page_props['data']
        details = page_props.get('details', {})

        has_episodes = len(page_props.get('episodes', ())) > 0 or len(page_props.get('audios', ())) > 0
        has_articles = len(page_props.get('articles', ())) > 0

        return self.playlist_result(
            self._entries(playlist_id, has_episodes, has_articles), playlist_id,
            details.get('name'), traverse_obj(details, ('description', 'lead')),
            thumbnail=details.get('photo'))


class PolskieRadioCategoryIE(InfoExtractor):
    # legacy sites
    IE_NAME = 'polskieradio:category'
    _VALID_URL = r'https?://(?:www\.)?polskieradio\.pl/\d+(?:,[^/]+)?/(?P<id>\d+)'
    _TESTS = [{
        'url': 'http://www.polskieradio.pl/7/129,Sygnaly-dnia?ref=source',
        'only_matching': True
    }, {
        'url': 'http://www.polskieradio.pl/37,RedakcjaKatolicka/4143,Kierunek-Krakow',
        'info_dict': {
            'id': '4143',
            'title': 'Kierunek Kraków',
        },
        'playlist_mincount': 61

Review comment (suggestion):
```suggestion
        page_props = traverse_obj(
            self._search_nextjs_data(self._download_webpage(url, playlist_id), playlist_id),
            ('props', 'pageProps', ('data', None)))
```

Code after:
            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 = [{
        'url': 'http://www.polskieradio.pl/7/129,Sygnaly-dnia?ref=source',
        'only_matching': True
    }, {
        'url': 'http://www.polskieradio.pl/37,RedakcjaKatolicka/4143,Kierunek-Krakow',
        'info_dict': {
            'id': '4143',
            'title': 'Kierunek Kraków',
        },
        'playlist_mincount': 61
    }, {
        'url': 'http://www.polskieradio.pl/10,czworka/214,muzyka',
        'info_dict': {
            'id': '214',
            'title': 'Muzyka',
        },
        'playlist_mincount': 61
    }, {
        'url': 'http://www.polskieradio.pl/8,Dwojka/196,Publicystyka',