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

Code before:
                'description': ('description', {str}),
                'artists': ('participants', ..., 'name', {str}, all),
                'tags': ('tags', ..., {str}),
            }),
        }


class IdagioPlaylistIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?app\.idagio\.com/playlists/(?!personal/)(?P<id>[\w-]+)'
    _TESTS = [{
        'url': 'https://app.idagio.com/playlists/beethoven-the-most-beautiful-piano-music',
        'info_dict': {
            'id': '31652bec-8c5b-460e-a3f0-cf1f69817f53',
            'display_id': 'beethoven-the-most-beautiful-piano-music',
            'title': 'Beethoven: the most beautiful piano music',
            'description': 'md5:d41bb04b8896bb69377f5c2cd9345ad1',
            'thumbnail': 'https://idagio-images.global.ssl.fastly.net/playlists/31652bec-8c5b-460e-a3f0-cf1f69817f53/main.jpg?_alt=sys/ph/artist-default.jpg',
            'creators': ['IDAGIO'],
        },
        'playlist_count': 17,
    }]

    def _real_extract(self, url):
        playlist_display_id = self._match_id(url)
        playlist_info = self._download_json(f'https://api.idagio.com/v2.0/playlists/{playlist_display_id}',
                                            playlist_display_id)['result']

        def construct_track_url(track_id, recording_id):
            return self.url_result(
                f'https://app.idagio.com/recordings/{recording_id}?trackId={track_id}',
                ie=IdagioTrackIE, video_id=track_id)

        return {
            '_type': 'playlist',
            'display_id': playlist_display_id,
            **traverse_obj(playlist_info, {
                'entries': ('tracks', ..., {
                    'track_id': ('id', {int}),
                    'recording_id': ('recording', 'id', {int}),
                }, {lambda ids: construct_track_url(**ids)}),
                'id': ('id', {str}),
                'title': ('title', {str}),
                'thumbnail': ('imageUrl', {url_or_none}),
                'description': ('description', {str}),
                'creators': ('curator', 'name', {str}, all),
            }),
        }


class IdagioPersonalPlaylistIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?app\.idagio\.com/playlists/personal/(?P<id>[\da-f-]+)'

Review comment (suggestion):
```suggestion
        playlist_info = self._download_json(
            f'https://api.idagio.com/v2.0/playlists/{playlist_display_id}', playlist_display_id)['result']
```

Code after:
            'thumbnail': ('imageUrl', {url_or_none}),
            'description': ('description', {str}),
            'artists': ('participants', ..., 'name', {str}),
            'tags': ('tags', ..., {str}),
        })


class IdagioPlaylistIE(IdagioPlaylistBaseIE):
    _VALID_URL = r'https?://(?:www\.)?app\.idagio\.com/playlists/(?!personal/)(?P<id>[\w-]+)'
    _TESTS = [{
        'url': 'https://app.idagio.com/playlists/beethoven-the-most-beautiful-piano-music',
        'info_dict': {
            'id': '31652bec-8c5b-460e-a3f0-cf1f69817f53',
            'display_id': 'beethoven-the-most-beautiful-piano-music',
            'title': 'Beethoven: the most beautiful piano music',
            'description': 'md5:d41bb04b8896bb69377f5c2cd9345ad1',
            'thumbnail': r're:https://.+/playlists/31652bec-8c5b-460e-a3f0-cf1f69817f53/main\.jpg',
            'creators': ['IDAGIO'],
        },
        'playlist_mincount': 16,  # one entry is geo-restricted
    }]
    _API_URL_TMPL = 'https://api.idagio.com/v2.0/playlists/{}'
    _PLAYLIST_ID_KEY = 'display_id'

    def _parse_playlist_metadata(self, playlist_info):
        return traverse_obj(playlist_info, {
            'id': ('id', {str}),
            'title': ('title', {str}),
            'thumbnail': ('imageUrl', {url_or_none}),
            'description': ('description', {str}),
            'creators': ('curator', 'name', {str}, all),
        })


class IdagioPersonalPlaylistIE(IdagioPlaylistBaseIE):
    _VALID_URL = r'https?://(?:www\.)?app\.idagio\.com/playlists/personal/(?P<id>[\da-f-]+)'
    _TESTS = [{
        'url': 'https://app.idagio.com/playlists/personal/99dad72e-7b3a-45a4-b216-867c08046ed8',
        'info_dict': {
            'id': '99dad72e-7b3a-45a4-b216-867c08046ed8',
            'title': 'Test',
            'creators': ['1a6f16a6-4514-4d0c-b481-3a9877835626'],
            'thumbnail': r're:https://.+/artists/86371/main\.jpg',
            'timestamp': 1602859138,
            'modified_timestamp': 1755616667,
            'upload_date': '20201016',
            'modified_date': '20250819',
        },
        'playlist_count': 100,
    }]
    _API_URL_TMPL = 'https://api.idagio.com/v1.0/personal-playlists/{}'