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)

        webpage = self._download_webpage(url, station_id)
        metadata = self._extract_metadata(webpage, station_id)

        formats, subtitles = self._extract_formats_and_subtitles(station_id)
        return {
            'id': station_id,
            'title': traverse_obj(metadata, ('profiles', station_id, 'title')),
            'description': traverse_obj(metadata, ('profiles', station_id, 'description')),
            'thumbnail': traverse_obj(metadata, ('profiles', station_id, 'image')),
            'timestamp': parse_iso8601(
                traverse_obj(metadata, ('profiles', station_id, 'actions', 'play', 'publishTime'))),
            'location': traverse_obj(
                metadata, ('profiles', station_id, 'metadata', 'properties', 'location', 'displayName'),
                ('profiles', station_id, 'properties', 'location', 'displayName')),
            'formats': formats,
            'subtitles': subtitles,
            'is_live': traverse_obj(metadata, ('profiles', station_id, 'actions', 'play', 'isLive')),
        }


class TuneInPodcastIE(TuneInBaseIE):
    _VALID_URL = TuneInBaseIE._VALID_URL_BASE + r'/(?:podcasts/[^?#]+-|embed/player/)(?P<id>p\d+)/?(?:[#?]|$)'
    _EMBED_REGEX = [r'<iframe[^>]+src=["\'](?P<url>(?:https?://)?tunein\.com/embed/player/p\d+)']

    _TESTS = [{
        'url': 'https://tunein.com/podcasts/Technology-Podcasts/Artificial-Intelligence-p1153019',
        'info_dict': {
            'id': 'p1153019',
            'title': 'Lex Fridman Podcast',
            'description': 'md5:bedc4e5f1c94f7dec6e4317b5654b00d',
        },
        'playlist_mincount': 200,
    }, {
        'url': 'https://tunein.com/embed/player/p191660/',
        'only_matching': True
    }, {
        'url': 'https://tunein.com/podcasts/World-News/BBC-News-p14/',
        'info_dict': {
            'id': 'p14',
            'title': 'BBC News',
            'description': 'md5:1218e575eeaff75f48ed978261fa2068',
        },
        'playlist_mincount': 200,
    }]

    _PAGE_SIZE = 30


Review comment (suggestion):
```suggestion
    _VALID_URL = TuneInBaseIE._VALID_URL_BASE + r'/(?:podcasts/[^?#]+-|embed/player/)(?P<id>p\d+)/?(?:#|$)'
```

Code after:

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

        webpage = self._download_webpage(url, station_id)
        metadata = self._extract_metadata(webpage, station_id)

        formats, subtitles = self._extract_formats_and_subtitles(station_id)
        return {
            'id': station_id,
            'title': traverse_obj(metadata, ('profiles', station_id, 'title')),
            'description': traverse_obj(metadata, ('profiles', station_id, 'description')),
            'thumbnail': traverse_obj(metadata, ('profiles', station_id, 'image')),
            'timestamp': parse_iso8601(
                traverse_obj(metadata, ('profiles', station_id, 'actions', 'play', 'publishTime'))),
            'location': traverse_obj(
                metadata, ('profiles', station_id, 'metadata', 'properties', 'location', 'displayName'),
                ('profiles', station_id, 'properties', 'location', 'displayName')),
            'formats': formats,
            'subtitles': subtitles,
            'is_live': traverse_obj(metadata, ('profiles', station_id, 'actions', 'play', 'isLive')),
        }


class TuneInPodcastIE(TuneInBaseIE):
    _VALID_URL = TuneInBaseIE._VALID_URL_BASE + r'/(?:podcasts/[^?#]+-|embed/player/)(?P<id>p\d+)/?(?:#|$)'
    _EMBED_REGEX = [r'<iframe[^>]+src=["\'](?P<url>(?:https?://)?tunein\.com/embed/player/p\d+)']

    _TESTS = [{
        'url': 'https://tunein.com/podcasts/Technology-Podcasts/Artificial-Intelligence-p1153019',
        'info_dict': {
            'id': 'p1153019',
            'title': 'Lex Fridman Podcast',
            'description': 'md5:bedc4e5f1c94f7dec6e4317b5654b00d',
        },
        'playlist_mincount': 200,
    }, {
        'url': 'https://tunein.com/embed/player/p191660/',
        'only_matching': True
    }, {
        'url': 'https://tunein.com/podcasts/World-News/BBC-News-p14/',
        'info_dict': {
            'id': 'p14',
            'title': 'BBC News',
            'description': 'md5:1218e575eeaff75f48ed978261fa2068',
        },
        'playlist_mincount': 200,
    }]

    _PAGE_SIZE = 30