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

Code before:
            'track_id': '30576943',
            'timestamp': 1554474370029,
        },
    }, {
        'url': 'https://api.idagio.com/v2.0/metadata/tracks/20514478',
        'md5': '3acef2ea0feadf889123b70e5a1e7fa7',
        'info_dict': {
            'id': '20514478',
            'ext': 'mp3',
            'title': 'Sonata for Piano No. 14 in C sharp minor op. 27/2: I. Adagio sostenuto',
            'duration': 316,
            'composers': ['Ludwig van Beethoven'],
            'artists': [],
            'genres': ['Keyboard', 'Sonata (Keyboard)'],
            'track': 'Sonata for Piano No. 14 in C sharp minor op. 27/2: I. Adagio sostenuto',
            'track_id': '20514478',
            'timestamp': 1518076337511,
        },
    }]

    def _real_extract(self, url):
        track_id: str = self._match_id(url)
        track_info: dict = self._download_json(f'https://api.idagio.com/v2.0/metadata/tracks/{track_id}',
                                               track_id).get('result')

        content_info: dict = self._download_json(f'https://api.idagio.com/v1.8/content/track/{track_id}?quality=0&format=2&client_type=web-4', track_id)

        work_name = traverse_obj(track_info, ('piece', 'workpart', 'work', 'title'))
        conductor = traverse_obj(track_info, ('recording', 'conductor', 'name'))
        artists = [] if conductor is None else [conductor]

        return {
            'id': str(traverse_obj(track_info, ('id',))),
            'title': work_name + ': ' + traverse_obj(track_info, ('piece', 'title')),
            'url': traverse_obj(content_info, ('url', )),
            'ext': 'mp3',
            'timestamp': traverse_obj(track_info, ('recording', 'created_at')),
            'location': traverse_obj(track_info, ('recording', 'location')),
            'duration': traverse_obj(track_info, ('duration',)),
            'track': work_name + ': ' + traverse_obj(track_info, ('piece', 'title')),
            'track_id': track_id,
            'artists': (artists + (traverse_obj(track_info, ('recording', 'ensembles', ..., 'name')) or [])
                        + (traverse_obj(track_info, ('recording', 'soloists', ..., 'name')) or [])),
            'composers': [traverse_obj(track_info, ('piece', 'workpart', 'work', 'composer', 'name'))],
            'genres': [traverse_obj(track_info, ('piece', 'workpart', 'work', 'genre', 'title')),
                       traverse_obj(track_info, ('piece', 'workpart', 'work', 'subgenre', 'title'))],
        }


class IdagioRecordingIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?app\.idagio\.com/recordings/(?P<id>[0-9]+)'

Review comment (suggestion):
yt-dlp code style would not include type information and break the lines differently. Also `track_info` is non-mandatory, right? So might as well make it non-fatal and get the `result` key below.
```suggestion
        track_id = self._match_id(url)
        track_info = self._download_json(
            f'https://api.idagio.com/v2.0/metadata/tracks/{track_id}', track_id, fatal=False)

        content_info = self._download_json(
            f'https://api.idagio.com/v1.8/content/track/{track_id}', track_id,
            query={
                'quality': '0',
                'format': '2',
                'client_type': 'web-4',
            })
```

Code after:
    }, {
        'url': 'https://app.idagio.com/recordings/20514467?trackId=20514478&utm_source=pcl',
        'md5': '3acef2ea0feadf889123b70e5a1e7fa7',
        'info_dict': {
            'id': '20514478',
            'ext': 'mp3',
            'title': 'I. Adagio sostenuto',
            'duration': 316,
            'composers': ['Ludwig van Beethoven'],
            'artists': [],
            'genres': ['Keyboard', 'Sonata (Keyboard)'],
            'track': 'I. Adagio sostenuto',
            'timestamp': 1518076337,
            'upload_date': '20180208',
        },
    }]

    def _real_extract(self, url):
        track_id = self._match_id(url)
        track_info = self._download_json(
            f'https://api.idagio.com/v2.0/metadata/tracks/{track_id}',
            track_id, fatal=False, expected_status=406)
        if traverse_obj(track_info, 'error_code') == 'idagio.error.blocked.location':
            self.raise_geo_restricted()

        content_info = self._download_json(
            f'https://api.idagio.com/v1.8/content/track/{track_id}', track_id,
            query={
                'quality': '0',
                'format': '2',
                'client_type': 'web-4',
            })

        return {
            'ext': 'mp3',
            'vcodec': 'none',
            'id': track_id,
            'url': traverse_obj(content_info, ('url', {url_or_none})),
            **traverse_obj(track_info, ('result', {
                'title': ('piece', 'title', {str}),
                'timestamp': ('recording', 'created_at', {int_or_none(scale=1000)}),
                'location': ('recording', 'location', {str}),
                'duration': ('duration', {int_or_none}),
                'track': ('piece', 'title', {str}),
                'artists': ('recording', ('conductor', ('ensembles', ...), ('soloists', ...)), 'name', {str}, filter),
                'composers': ('piece', 'workpart', 'work', 'composer', 'name', {str}, filter, all, filter),
                'genres': ('piece', 'workpart', 'work', ('genre', 'subgenre'), 'title', {str}, filter),
            })),
        }