我正在制作一个不和谐的歌词机器人并接收歌词。我正在使用GeniusAPI(lyricsgenius
API包装器)。但当我收到歌词时,结尾是:
“away”是这首歌的最后一个词,但它伴随着EmbedShare URLCopyEmbedCopy
。有时它只是简单的歌词,没有EmbedShare
文本
用同一首歌:
有没有办法防止这种情况发生
lyrics
命令的源代码:
@commands.command(help="Gives the lyrics of the song XD! format //lyrics (author) (song name)")
async def lyrics(self, ctx, arg1, arg2):
song = genius.search_song(arg1, arg2)
print(song.lyrics)
name = ("Lyrics for " + arg2.capitalize() + " by " + arg1.capitalize())
gembed = discord.Embed(title=name.capitalize(), description=song.lyrics)
await ctx.send(embed=gembed)
Some Random API是一种很容易处理的方法,当您创建一个命令来发送歌词时
这是如何使用一些随机api实现的
这是一个已知的
lyricsgenius
错误,有一个开放的PR来解决这个问题:https://github.com/johnwmillr/LyricsGenius/pull/215这是因为
lyricsgenius
web从Genius的网站上删除歌词,这意味着如果他们的网站更新,lyricsgenius
将无法获取歌词。此库已6个月未更新;它本身就是一个web废弃库,这意味着这种不活动将使库严重不稳定。由于该库是根据MIT授权的,因此您可以分叉该库并为您的项目/机器人维护最新版本。不过,最好使用专用API来获取歌曲歌词,以保证稳定性另外,} 。
lyricsgenius
使用同步requests
库,这意味着它将在获取歌词时“阻止”异步bot。这对于Discord机器人来说绝对是不可取的,因为你的机器人在获取歌词时会完全没有响应。考虑在调用阻塞函数时使用^ {CD6}}重写它或使用^{相关问题 更多 >
编程相关推荐