【问题标题】:When I use the Genius API, it doesn't give me the full lyrics当我使用 Genius API 时,它没有给我完整的歌词
【发布时间】:2021-07-06 11:22:34
【问题描述】:

当我运行这段代码 (discord.py) 时,我没有得到完整的歌词:

@commands.command()
async def lyrics(self, ctx, arg1, arg2):
    song = genius.search_song(arg2, arg1)
    print(song)
    embedgenius = discord.Embed(title=arg2.capitalize(), description=arg1.capitalize(), colour=0x69ff00)
    embedgenius.add_field(name="Lyrics:", value=song)
    await ctx.send(embed=embedgenius)

我明白了:

示例 Polo G - Rapstar:

"RAPSTAR" by Polo G:
[Intro]
(Shout out my n**** Synco)

[Chorus]
Uh (Tuned up), copped a BMW, new deposit, I picked up a...

【问题讨论】:

    标签: python discord.py genius-api


    【解决方案1】:

    您将歌曲设置为值,而不是歌词。

    embedgenius.add_field(name="Lyrics:", value=song)

    您基本上是在打印歌曲对象,其中包含部分歌词只是巧合。要打印歌曲的歌词,请使用song.lyrics。但是您应该记住,嵌入字段限制为 1024 个字符。


    @commands.command()
    async def lyrics(self, ctx, arg1, arg2):
        song = genius.search_song(arg2, arg1)
        print(song.lyrics)
        embedgenius = discord.Embed(title=arg2.capitalize(), description=arg1.capitalize(), colour=0x69ff00)
        embedgenius.add_field(name="Lyrics:", value=song.lyrics)
        await ctx.send(embed=embedgenius)
    

    【讨论】:

      猜你喜欢
      • 2020-09-16
      • 1970-01-01
      • 1970-01-01
      • 2014-09-12
      • 2021-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-09
      相关资源
      最近更新 更多