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

Code before:
    int_or_none,
    parse_iso8601,
    update_url_query,
    url_or_none,
)
from ..utils.traversal import traverse_obj


class TuneInBaseIE(InfoExtractor):
    def _call_api(self, item_id, endpoint=None, note='Downloading JSON metadata', query=None):
        path = f'/{endpoint}' if endpoint else ''

        return self._download_json(
            f'https://api.tunein.com/profiles/{item_id}{path}', item_id, note=note, query=query)

    def _extract_formats_and_subtitles(self, content_id):
        streams = self._download_json(
            'https://opml.radiotime.com/Tune.ashx', content_id, query={
                'formats': 'mp3,aac,ogg,flash,hls',
                'id': content_id,
                'render': 'json',
            },
        )['body']

        formats, subtitles = [], {}
        for stream in streams:
            if stream.get('media_type') == 'hls':
                fmts, subs = self._extract_m3u8_formats_and_subtitles(stream['url'], content_id, fatal=False)
                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            else:
                formats.append(traverse_obj(stream, {
                    'abr': ('bitrate', {int_or_none}),
                    'ext': ('media_type', {str}),
                    'url': ('url', {self._proto_relative_url}, {url_or_none}),
                }))

        return formats, subtitles


class TuneInStationIE(TuneInBaseIE):
    IE_NAME = 'tunein:station'
    _VALID_URL = r'https?://tunein\.com/radio/[^/]+(?P<id>s\d+)'
    _TESTS = [{
        'url': 'https://tunein.com/radio/Jazz24-885-s34682/',
        'info_dict': {
            'id': 's34682',
            'ext': 'mp3',
            'title': str,
            'alt_title': 'World Class Jazz',
            'channel_follower_count': int,

Review comment (suggestion):
let's filter here
```suggestion
        for stream in traverse_obj(streams, ('body', lambda _, v: url_or_none(v['url']))):
```

Code after:
    UnsupportedError,
    clean_html,
    int_or_none,
    join_nonempty,
    parse_iso8601,
    update_url_query,
    url_or_none,
)
from ..utils.traversal import traverse_obj


class TuneInBaseIE(InfoExtractor):
    def _call_api(self, item_id, endpoint=None, note='Downloading JSON metadata', fatal=False, query=None):
        return self._download_json(
            join_nonempty('https://api.tunein.com/profiles', item_id, endpoint, delim='/'),
            item_id, note=note, fatal=fatal, query=query) or {}

    def _extract_formats_and_subtitles(self, content_id):
        streams = self._download_json(
            'https://opml.radiotime.com/Tune.ashx', content_id, query={
                'formats': 'mp3,aac,ogg,flash,hls',
                'id': content_id,
                'render': 'json',
            })

        formats, subtitles = [], {}
        for stream in traverse_obj(streams, ('body', lambda _, v: url_or_none(v['url']))):
            if stream.get('media_type') == 'hls':
                fmts, subs = self._extract_m3u8_formats_and_subtitles(stream['url'], content_id, fatal=False)
                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            else:
                formats.append(traverse_obj(stream, {
                    'abr': ('bitrate', {int_or_none}),
                    'ext': ('media_type', {str}),
                    'url': ('url', {self._proto_relative_url}),
                }))

        return formats, subtitles


class TuneInStationIE(TuneInBaseIE):
    IE_NAME = 'tunein:station'
    _VALID_URL = r'https?://tunein\.com/radio/[^/?#]+(?P<id>s\d+)'
    _TESTS = [{
        'url': 'https://tunein.com/radio/Jazz24-885-s34682/',
        'info_dict': {
            'id': 's34682',
            'ext': 'mp3',
            'title': str,
            'alt_title': 'World Class Jazz',