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

Code before:
                format_id = http_f['format_id'].replace('hls-', 'https-')
                urlh = self._request_webpage(
                    HEADRequest(http_url), video_id,
                    note=f'Check filesize for {format_id}', fatal=False)
                if urlh:
                    http_f.update({
                        'format_id': format_id,
                        'url': http_url,
                        'protocol': 'https',
                        'filesize_approx': int_or_none(urlh.headers.get('Content-Length', None)),
                    })
                    http_formats.append(http_f)

        return http_formats

    def _create_formats(self, sources, video_id):
        formats = []

        for source in sources:
            if source['type'] == 'm3u8':
                m3u8_formats = self._extract_m3u8_formats(
                    source['url'], video_id, 'mp4', m3u8_id='hls', fatal=False)
                formats.extend(m3u8_formats)
                http_formats = self._create_http_formats(source['url'], m3u8_formats or [], video_id)
                formats.extend(http_formats)
            if source['type'] == 'mp3':
                formats.append({
                    'format_id': 'https-mp3',
                    'ext': 'mp3',
                    'acodec': 'mp3',
                    'vcodec': 'none',
                    'abr': source.get('bitrate'),
                    'url': source['url'],
                })

        return formats

    def _real_extract(self, url):
        mobj = self._match_valid_url(url)
        video_id = mobj.group('id')

        if 'cdn' not in mobj.groupdict():
            raise ExtractorError('CDN not found in url: %s' % url)

        # for leitv/youreporter don't use the embed page
        if mobj.group('cdn') not in ['leitv.it', 'youreporter.it']:
            if 'video-embed' not in url and not re.match(self._UUID_RE, video_id):
                page = self._download_webpage(url, video_id)
                video_id = self._search_regex(fr'"uuid"\s*:\s*"({self._UUID_RE})"', page, video_id, fatal=False) or video_id
            url = 'https://video.%s/video-embed/%s' % (mobj.group('cdn'), video_id)


Review comment (suggestion):
```suggestion
                formats.extend(self._create_http_formats(
                    source['url'], m3u8_formats or [], video_id))
            elif source['type'] == 'mp3':
```

Code after:
            yield http_f

    def _create_formats(self, sources, video_id):
        for source in sources:
            if source['type'] == 'm3u8':
                m3u8_formats = self._extract_m3u8_formats(
                    source['url'], video_id, 'mp4', m3u8_id='hls', fatal=False)
                yield from m3u8_formats
                yield from self._create_http_formats(m3u8_formats, video_id)
            elif source['type'] == 'mp3':
                yield {
                    'format_id': 'https-mp3',
                    'ext': 'mp3',
                    'acodec': 'mp3',
                    'vcodec': 'none',
                    'abr': source.get('bitrate'),
                    'url': source['url'],
                }

    def _real_extract(self, url):
        cdn, video_id = self._match_valid_url(url).group('cdn', 'id')
        display_id, video_data = None, None

        if re.match(self._UUID_RE, video_id) or re.match(self._RCS_ID_RE, video_id):
            url = f'https://video.{cdn}/video-json/{video_id}'
        else:
            webpage = self._download_webpage(url, video_id)
            data_config = get_element_html_by_id('divVideoPlayer', webpage) or get_element_html_by_class('divVideoPlayer', webpage)

            if data_config:
                data_config = self._parse_json(
                    extract_attributes(data_config).get('data-config'),
                    video_id, fatal=False) or {}
                if data_config.get('newspaper'):
                    cdn = f'{data_config["newspaper"]}.it'
                display_id, video_id = video_id, data_config.get('uuid') or video_id
                url = f'https://video.{cdn}/video-json/{video_id}'
            else:
                json_url = self._search_regex(
                    r'''(?x)url\s*=\s*(["'])
                    (?P<url>
                        (?:https?:)?//video\.rcs\.it
                        /fragment-includes/video-includes/[^"']+?\.json
                    )\1;''',
                    webpage, video_id, group='url', default=None)
                if json_url:
                    video_data = self._download_json(sanitize_url(json_url, scheme='https'), video_id)
                    display_id, video_id = video_id, video_data.get('id') or video_id

        if not video_data:
            webpage = self._download_webpage(url, video_id)