gpt4 book ai didi

python - "FFmpeg was not found, spotdl can' t continue”,即使它是使用 sudo apt-get install spotdl 安装的 + 如果从终端运行它也可以工作

转载 作者:行者123 更新时间:2023-12-04 23:32:52 26 4
gpt4 key购买 nike

@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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com