def spotifyinfo(self, ctx, url : str):
'''Information about a Spotify track'''
path = urllib.parse.urlparse(url).path
if path[:7] != "/track/":
await self.bot.embed_reply(":no_entry: Syntax error")
return
trackid = path[7:]
api_url = "https://api.spotify.com/v1/tracks/" + trackid
async with clients.aiohttp_session.get(api_url) as resp:
data = await resp.json()
# tracknumber = str(data["track_number"])
description = "Artist: [{}]({})\n".format(data["artists"][0]["name"], data["artists"][0]["external_urls"]["spotify"])
description += "Album: [{}]({})\n".format(data["album"]["name"], data["album"]["external_urls"]["spotify"])
description += "Duration: {}\n".format(utilities.secs_to_colon_format(data["duration_ms"] / 1000))
description += "[Preview]({})".format(data["preview_url"])
await self.bot.embed_reply(description, title = data["name"], title_url = url, thumbnail_url = data["album"]["images"][0]["url"])
评论列表
文章目录