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

Code before:
    }]

    def _real_extract(self, url):
        station_id = self._match_id(url)
        formats, subtitles = self._extract_formats_and_subtitles(station_id)

        return {
            'id': station_id,
            'formats': formats,
            'subtitles': subtitles,
            **traverse_obj(self._call_api(station_id), ('Item', {
                'title': ('Title', {clean_html}),
                'alt_title': ('Subtitle', {clean_html}, filter),
                'channel_follower_count': ('Actions', 'Follow', 'FollowerCount', {int_or_none}),
                'description': ('Description', {clean_html}, filter),
                'is_live': ('Actions', 'Play', 'IsLive', {bool}),
                'location': ('Properties', 'Location', 'DisplayName', {str}, any),
                'thumbnail': ('Image', {url_or_none}),
            })),
        }


class TuneInPodcastIE(TuneInBaseIE):
    IE_NAME = 'tunein:podcast:program'
    _PAGE_SIZE = 20
    _VALID_URL = r'https?://tunein\.com/podcasts(?:/[^/?#]+)?/[^/?#]+(?P<id>p\d+)/?(?:\?(?![^#]*(?i:\btopicid)=)[^#]*)?(?:#|$)'
    _TESTS = [{
        'url': 'https://tunein.com/podcasts/Technology-Podcasts/Artificial-Intelligence-p1153019/',
        'info_dict': {
            'id': 'p1153019',
            'title': 'Lex Fridman Podcast',
        },
        'playlist_mincount': 200,
    }, {
        'url': 'https://tunein.com/podcasts/World-News/BBC-News-p14/',
        'info_dict': {
            'id': 'p14',
            'title': 'BBC News',
        },
        'playlist_mincount': 35,
    }]

    def _entries(self, podcast_id):
        for page in itertools.count():
            contents = self._call_api(
                podcast_id, 'contents',
                f'Downloading page {page + 1}', query={
                    'filter': 't:free',
                    'limit': self._PAGE_SIZE,
                    'offset': page * self._PAGE_SIZE,
                })

Review comment (refactor):
I'd be in favor of simplifying the regex and overriding `suitable()`
```suggestion
    _VALID_URL = r'https?://tunein\.com/podcasts(?:/[^/?#]+){1,2}(?P<id>p\d+)'
```

Code after:
        'params': {'skip_download': 'Livestream'},
    }]

    def _real_extract(self, url):
        station_id = self._match_id(url)
        formats, subtitles = self._extract_formats_and_subtitles(station_id)

        return {
            'id': station_id,
            'formats': formats,
            'subtitles': subtitles,
            **traverse_obj(self._call_api(station_id), ('Item', {
                'title': ('Title', {clean_html}),
                'alt_title': ('Subtitle', {clean_html}, filter),
                'channel_follower_count': ('Actions', 'Follow', 'FollowerCount', {int_or_none}),
                'description': ('Description', {clean_html}, filter),
                'is_live': ('Actions', 'Play', 'IsLive', {bool}),
                'location': ('Properties', 'Location', 'DisplayName', {str}),
                'thumbnail': ('Image', {url_or_none}),
            })),
        }


class TuneInPodcastIE(TuneInBaseIE):
    IE_NAME = 'tunein:podcast:program'
    _PAGE_SIZE = 20
    _VALID_URL = r'https?://tunein\.com/podcasts(?:/[^/?#]+){1,2}(?P<id>p\d+)'
    _TESTS = [{
        'url': 'https://tunein.com/podcasts/Technology-Podcasts/Artificial-Intelligence-p1153019/',
        'info_dict': {
            'id': 'p1153019',
            'title': 'Lex Fridman Podcast',
        },
        'playlist_mincount': 200,
    }, {
        'url': 'https://tunein.com/podcasts/World-News/BBC-News-p14/',
        'info_dict': {
            'id': 'p14',
            'title': 'BBC News',
        },
        'playlist_mincount': 35,
    }]

    @classmethod
    def suitable(cls, url):
        return False if TuneInPodcastEpisodeIE.suitable(url) else super().suitable(url)

    def _fetch_page(self, url, podcast_id, page=0):
        items = self._call_api(
            podcast_id, 'contents', f'Downloading page {page + 1}', query={
                'filter': 't:free',