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

Code before:
            'live': True,
            'ext': 'aac',
        },
        'params': {
            'skip_download': 'Livestream',
        },
    }, {
        'url': 'https://www.radiofrance.fr/mouv',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        station_id, substation_id = self._match_valid_url(url).group('id', 'substation_id')

        if substation_id:
            webpage = self._download_webpage(url, station_id)

            api_response = self._parse_json(self._search_json(
                r'<script[^>]+type\s*=\s*"application/json"[^>]+/webradios/[^>]+>',
                webpage, 'substation_data', station_id)['body'], station_id)
        else:
            api_response = self._download_json(
                f'https://www.radiofrance.fr/api/v2.1/stations/{station_id}/live', station_id)

        formats, subtitles = [], {}
        for media_source in traverse_obj(api_response, ('now', 'media', 'sources'), ('media', 'sources')):
            if media_source.get('format') == 'hls':
                fmts, subs = self._extract_m3u8_formats_and_subtitles(media_source['url'], station_id, fatal=False)
                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            else:
                formats.append({
                    'url': media_source['url'],
                    'abr': media_source.get('bitrate'),
                })

        return {
            'id': join_nonempty(station_id, substation_id, delim='-'),
            'title': traverse_obj(api_response, ('visual', 'legend')) or join_nonempty(
                traverse_obj(api_response, ('now', 'firstLine', 'title')),
                traverse_obj(api_response, ('now', 'secondLine', 'title')), delim=" - "),
            'formats': formats,
            'subtitles': subtitles,
            'live': True,
        }


class RadioFrancePlaylistBase(RadioFranceBase):
    """Subclasses must set _METADATA_KEY"""

    def _generate_playlist_entries(self, content_id, content_response):

Review comment (suggestion):
```suggestion
        for media_source in traverse_obj(
                api_response, (('now', None), 'media', 'sources'), get_all=False):
```

Code after:
        'params': {
            'skip_download': 'Livestream',
        },
    }, {
        'url': 'https://www.radiofrance.fr/fip/radio-rock',
        'info_dict': {
            'id': 'fip-radio-rock',
            'title': str,
            'live_status': 'is_live',
            'ext': 'aac',
        },
        'params': {
            'skip_download': 'Livestream',
        },
    }, {
        'url': 'https://www.radiofrance.fr/mouv',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        station_id, substation_id = self._match_valid_url(url).group('id', 'substation_id')

        if substation_id:
            webpage = self._download_webpage(url, station_id)
            api_response = self._extract_data_from_webpage(webpage, station_id, 'webRadioData')
        else:
            api_response = self._download_json(
                f'https://www.radiofrance.fr/{station_id}/api/live', station_id)

        formats, subtitles = [], {}
        for media_source in traverse_obj(api_response, (('now', None), 'media', 'sources', lambda _, v: v['url'])):
            if media_source.get('format') == 'hls':
                fmts, subs = self._extract_m3u8_formats_and_subtitles(media_source['url'], station_id, fatal=False)
                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            else:
                formats.append({
                    'url': media_source['url'],
                    'abr': media_source.get('bitrate'),
                })

        return {
            'id': join_nonempty(station_id, substation_id),
            'title': traverse_obj(api_response, ('visual', 'legend')) or join_nonempty(
                ('now', 'firstLine', 'title'), ('now', 'secondLine', 'title'), from_dict=api_response, delim=' - '),
            'formats': formats,
            'subtitles': subtitles,
            'is_live': True,
        }