Fix Apple Music artwork error

This commit is contained in:
Parker M. 2024-07-20 18:09:41 -05:00
parent c40b632d46
commit 1614fa2dfa
No known key found for this signature in database
GPG Key ID: 95CD2E0C7E329F2A

View File

@ -58,9 +58,12 @@ class Play(commands.Cog):
playlist_info_url = f"https://api.music.apple.com/v1/catalog/us/playlists/{playlist_id}"
playlist_info = requests.get(playlist_info_url, headers=apple_headers)
playlist_info = playlist_info.json()
artwork_url = playlist_info["data"][0]["attributes"]["artwork"]["url"].replace(
"{w}x{h}", "300x300"
)
try:
artwork_url = playlist_info["data"][0]["attributes"]["artwork"]["url"].replace(
"{w}x{h}", "300x300"
)
except KeyError:
artwork_url = None
embed.title = "Playlist Queued"
embed.description = f"**{playlist_info['data'][0]['attributes']['name']}**\n` {len(playlist['data'])} ` tracks\n\nQueued by: {interaction.user.mention}"