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

Code before:
            episodes = self._download_json(
                f'https://api.spreaker.com/show/{show_id}/episodes',
                show_id, note=f'Downloading JSON page {page_num}', query={
                    'page': page_num,
                    'max_per_page': 100,
                })
            pager = try_get(episodes, lambda x: x['response']['pager'], dict)
            if not pager:
                break
            results = pager.get('results')
            if not results or not isinstance(results, list):
                break
            for result in results:
                if not isinstance(result, dict):
                    continue
                yield _extract_episode(result)
            if page_num == pager.get('last_page'):
                break

    def _real_extract(self, url):
        show_id = self._match_id(url)
        return self.playlist_result(self._entries(show_id), playlist_id=show_id)


class SpreakerShowPageIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?spreaker\.com/show/(?P<id>[^/?#&]+)(?!/episodes/feed)'
    _TESTS = [{
        'url': 'https://www.spreaker.com/show/success-with-music',
        'info_dict': {
            'id': '2317431',
        },
        'playlist_mincount': 30,
    }]

    def _real_extract(self, url):
        display_id = self._match_id(url)
        webpage = self._download_webpage(url, display_id)
        redirect_url = self._og_search_property('url', webpage, 'redirect url')
        return self.url_result(
            redirect_url,
            SpreakerPodcastPageIE)


class SpreakerPodcastPageIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?spreaker\.com/podcast/[\w-]+--(?P<id>[\d]+)'
    _TESTS = [{
        'url': 'https://www.spreaker.com/podcast/health-wealth--5918323',
        'info_dict': {
            'id': '5918323',
        },
        'playlist_mincount': 60,

Review comment (suggestion):
```suggestion
    _VALID_URL = r'https?://(?:www\.)?spreaker\.com/show/(?P<id>[^/?#&]+)(?:[?#]|$)(?!/episodes/feed)'
```

Code after:
            'id': '4652058',
        },
        'playlist_mincount': 118,
    }, {
        'url': 'https://www.spreaker.com/podcast/health-wealth--5918323',
        'info_dict': {
            'id': '5918323',
        },
        'playlist_mincount': 60,
    }, {
        'url': 'https://www.spreaker.com/show/5887186/episodes/feed',
        'info_dict': {
            'id': '5887186',
        },
        'playlist_mincount': 290,
    }]

    def _entries(self, show_id, key=None):
        for page_num in itertools.count(1):
            episodes = self._download_json(
                f'https://api.spreaker.com/show/{show_id}/episodes',
                show_id, note=f'Downloading JSON page {page_num}', query=filter_dict({
                    'page': page_num,
                    'max_per_page': 100,
                    'key': key,
                }))
            pager = try_get(episodes, lambda x: x['response']['pager'], dict)
            if not pager:
                break
            results = pager.get('results')
            if not results or not isinstance(results, list):
                break
            for result in results:
                if not isinstance(result, dict):
                    continue
                yield _extract_episode(result)
            if page_num == pager.get('last_page'):
                break

    def _real_extract(self, url):
        show_id = self._match_id(url)
        key = traverse_obj(parse_qs(url), ('key', 0))
        return self.playlist_result(self._entries(show_id, key), playlist_id=show_id)