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

Code before:
            'format_id': 'default',
            'quality': 1,
        }, fatal=True)
        # the formats below don't always exist
        add_format({
            'url': f'{track_url}/player_asset?quality=hd',
            'format_id': 'hd',
            'quality': 10,
        }, fatal=False)
        add_format({
            'url': f'{track_url}/download',
            'format_id': 'download',
            'quality': 11,
        }, fatal=False)

        return {
            'id': track_id,
            'formats': formats,
            'artist': ', '.join(artists),
            'genre': genre,
            **traverse_obj(json, {
                'title': ('title', {str}),
                'composer': ('composer_name', {str}),
                'thumbnail': (('picture_url_xlarge', 'picture_url'), {url_or_none}),
            }, get_all=False),
        }


class Mx3IE(Mx3BaseIE):
    _MX3_DOMAIN = 'mx3.ch'
    _VALID_URL = r'https?://(?:www\.)?mx3\.ch/t/(?P<id>[0-9A-Za-z]+)'
    _TESTS = [{
        'url': 'https://mx3.ch/t/1Cru',
        'md5': '82510bf4c21f17da41bff7e1ffd84e78',
        'info_dict': {
            'id': '1Cru',
            # This one is audio-only. It's a mp3, but we have to make a HEAD request to find out.
            'ext': 'mp3',
            'artist': 'Tortue Tortue, Godina',
            'composer': 'Olivier Godinat',
            'genre': 'Rock',
            'thumbnail': 'https://mx3.ch/pictures/mx3/file/0101/4643/square_xlarge/1-s-envoler-1.jpg?1630272813',
            'title': 'S\'envoler',
            'timestamp': 1630272831,
        }
    }, {
        'url': 'https://mx3.ch/t/1LIY',
        'md5': '4117489dff8c763ecfbb0b95a67d6c8e',
        'info_dict': {
            'id': '1LIY',
            # This is a music video. 'file' says: ISO Media, MP4 Base Media v1 [ISO 14496-12:2003]

Review comment (refactor):
Okay, I wrote a function to extract more metadata fields. For artist/performer, how about we split this across `artist` and `album_artist`, with a fallback for `artist`.
```suggestion
        more_info = get_element_by_class('single-more-info', webpage)

        def get_info_field(name):
            return self._html_search_regex(
                rf'<dt[^>]*>\s*{name}\s*</dt>\s*<dd[^>]*>(.*?)</dd>',
                more_info, name, default=None, flags=re.DOTALL)

        return {
            'id': track_id,
            'formats': formats,
            'genre': self._html_search_regex(
                r'<div\b[^>]+class="single-band-genre"[^>]*>([^<]+)</div>', webpage, 'genre', fatal=False),
            'release_year': int_or_none(get_info_field('Year of creation')),
            'description ': get_info_field('Description'),
            'tags': try_call(lambda: get_info_field('Tag').split(', '), list),
            **traverse_obj(data, {
                'title': ('title', {str}),
                'artist': (('performer_name', 'artist'), {str}),
                'album_artist': ('artist', {str}),
                'composer': ('composer_name', {str}),
                'thumbnail': (('picture_url_xlarge', 'picture_url'), {url_or_none}),
            }, get_all=False),
        }
```

Code after:
        return formats

    def _real_extract(self, url):
        track_id = self._match_id(url)
        webpage = self._download_webpage(url, track_id)
        more_info = get_element_by_class('single-more-info', webpage)
        data = self._download_json(f'https://{self._DOMAIN}/t/{track_id}.json', track_id, fatal=False)

        def get_info_field(name):
            return self._html_search_regex(
                rf'<dt[^>]*>\s*{name}\s*</dt>\s*<dd[^>]*>(.*?)</dd>',
                more_info, name, default=None, flags=re.DOTALL)

        return {
            'id': track_id,
            'formats': self._extract_formats(track_id),
            'genre': self._html_search_regex(
                r'<div\b[^>]+class="single-band-genre"[^>]*>([^<]+)</div>', webpage, 'genre', default=None),
            'release_year': int_or_none(get_info_field('Year of creation')),
            'description': get_info_field('Description'),
            'tags': try_call(lambda: get_info_field('Tag').split(', '), list),
            **traverse_obj(data, {
                'title': ('title', {str}),
                'artist': (('performer_name', 'artist'), {str}),
                'album_artist': ('artist', {str}),
                'composer': ('composer_name', {str}),
                'thumbnail': (('picture_url_xlarge', 'picture_url'), {url_or_none}),
            }, get_all=False),
        }


class Mx3IE(Mx3BaseIE):
    _DOMAIN = 'mx3.ch'
    _VALID_URL = Mx3BaseIE._VALID_URL_TMPL % re.escape(_DOMAIN)
    _TESTS = [{
        'url': 'https://mx3.ch/t/1Cru',
        'md5': '7ba09e9826b4447d4e1ce9d69e0e295f',
        'info_dict': {
            'id': '1Cru',
            'ext': 'wav',
            'artist': 'Godina',
            'album_artist': 'Tortue Tortue',
            'composer': 'Olivier Godinat',
            'genre': 'Rock',
            'thumbnail': 'https://mx3.ch/pictures/mx3/file/0101/4643/square_xlarge/1-s-envoler-1.jpg?1630272813',
            'title': "S'envoler",
            'release_year': 2021,
            'tags': [],
        }
    }, {
        'url': 'https://mx3.ch/t/1LIY',