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

Code before:
    """Subclasses must set _API_URL_TMPL and define _parse_playlist_metadata"""
    _PLAYLIST_ID_KEY = 'id'  # vs. 'display_id'

    def _entries(self, playlist_info):
        for track_data in traverse_obj(playlist_info, ('tracks', lambda _, v: v['id'] and v['recording']['id'])):
            track_id = track_data['id']
            recording_id = track_data['recording']['id']
            yield self.url_result(
                f'https://app.idagio.com/recordings/{recording_id}?trackId={track_id}',
                ie=IdagioTrackIE, video_id=track_id)

    def _real_extract(self, url):
        playlist_id = self._match_id(url)
        playlist_info = self._download_json(
            self._API_URL_TMPL.format(playlist_id), playlist_id)['result']

        return {
            '_type': 'playlist',
            self._PLAYLIST_ID_KEY: playlist_id,
            'entries': self._entries(playlist_info),
            **self._parse_playlist_metadata(playlist_info),
        }


class IdagioRecordingIE(IdagioPlaylistBaseIE):
    _VALID_URL = r'https?://(?:www\.)?app\.idagio\.com(?:/[a-z]+)?/recordings/(?P<id>\d+)(?![^#]*[&?]trackId=\d+)'
    _TESTS = [{
        'url': 'https://app.idagio.com/recordings/30576934',
        'info_dict': {
            'id': '30576934',
            'title': 'Variations on an Original Theme op. 36',
            'composers': ['Edward Elgar'],
            'artists': ['Vasily Petrenko', 'Royal Liverpool Philharmonic Orchestra'],
            'genres': ['Orchestral', 'Other Orchestral Music'],
            'timestamp': 1554474370,
            'modified_timestamp': 1554474370,
            'modified_date': '20190405',
            'upload_date': '20190405',
        },
        'playlist_count': 15,
    }, {
        'url': 'https://app.idagio.com/de/recordings/20514467',
        'info_dict': {
            'id': '20514467',
            'title': 'Sonata for Piano No. 14 in C sharp minor op. 27/2',
            'composers': ['Ludwig van Beethoven'],
            'genres': ['Keyboard', 'Sonata (Keyboard)'],
            'timestamp': 1518076337,
            'upload_date': '20180208',
            'modified_timestamp': 1518076337,
            'modified_date': '20180208',

Review comment (suggestion):
```suggestion
    _VALID_URL = r'https?://(?:www\.)?app\.idagio\.com(?:/[a-z]{2})?/recordings/(?P<id>\d+)(?![^#]*[&?]trackId=\d+)'
```

Code after:


class IdagioPlaylistBaseIE(InfoExtractor):
    """Subclasses must set _API_URL_TMPL and define _parse_playlist_metadata"""
    _PLAYLIST_ID_KEY = 'id'  # vs. 'display_id'

    def _entries(self, playlist_info):
        for track_data in traverse_obj(playlist_info, ('tracks', lambda _, v: v['id'] and v['recording']['id'])):
            track_id = track_data['id']
            recording_id = track_data['recording']['id']
            yield self.url_result(
                f'https://app.idagio.com/recordings/{recording_id}?trackId={track_id}',
                ie=IdagioTrackIE, video_id=track_id)

    def _real_extract(self, url):
        playlist_id = self._match_id(url)
        playlist_info = self._download_json(
            self._API_URL_TMPL.format(playlist_id), playlist_id)['result']

        return {
            '_type': 'playlist',
            self._PLAYLIST_ID_KEY: playlist_id,
            'entries': self._entries(playlist_info),
            **self._parse_playlist_metadata(playlist_info),
        }


class IdagioRecordingIE(IdagioPlaylistBaseIE):
    _VALID_URL = r'https?://(?:www\.)?app\.idagio\.com(?:/[a-z]{2})?/recordings/(?P<id>\d+)(?![^#]*[&?]trackId=\d+)'
    _TESTS = [{
        'url': 'https://app.idagio.com/recordings/30576934',
        'info_dict': {
            'id': '30576934',
            'title': 'Variations on an Original Theme op. 36',
            'composers': ['Edward Elgar'],
            'artists': ['Vasily Petrenko', 'Royal Liverpool Philharmonic Orchestra'],
            'genres': ['Orchestral', 'Other Orchestral Music'],
            'timestamp': 1554474370,
            'modified_timestamp': 1554474370,
            'modified_date': '20190405',
            'upload_date': '20190405',
        },
        'playlist_count': 15,
    }, {
        'url': 'https://app.idagio.com/de/recordings/20514467',
        'info_dict': {
            'id': '20514467',
            'title': 'Sonata for Piano No. 14 in C sharp minor op. 27/2',
            'composers': ['Ludwig van Beethoven'],
            'genres': ['Keyboard', 'Sonata (Keyboard)'],
            'timestamp': 1518076337,