@bot.command()
async def getsong(ctx, *, songname):
"get song in mp3 from song name"
os.popen(f'spotdl {songname} -f "/home/pi/discordbot/output/{songname}.mp3"')
await ctx.send(file=discord.File(fr'/home/pi/discordbot/output/{songname}.mp3'))
使用 sudo-apt get 安装的 ffmpeg。如果从终端运行则有效怎么修?
我自己弄清楚了。
工作代码,如果它有利于任何人:
@bot.command()
async def getsong(ctx, *, songname):
"get song in mp3 from song name"
subprocess.Popen(f'spotdl -o "/home/pi/discordbot/output" --ffmpeg "/usr/bin/ffmpeg" {songname} --path-template "{songname}.mp3"', shell=True)
await ctx.send(file=discord.File(fr'/home/pi/discordbot/output/{songname}.mp3'))
最佳答案
尝试使用 subprocess.check_output
来自子流程,例如
@bot.command()
async def getsong(ctx, *, songname):
# get song in mp3 from song name :D
subprocess.check_output(f'spotdl {songname} -f "/home/pi/discordbot/output/{songname}.mp3"', shell=True)
await ctx.send(file=discord.File(f'/home/pi/discordbot/output/{songname}.mp3'))
关于python - "FFmpeg was not found, spotdl can' t continue”,即使它是使用 sudo apt-get install spotdl 安装的 + 如果从终端运行它也可以工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72706502/