youtube_dl linux 的 outtmpl 格式
youtube_dl outtmpl format for linux
queue_path = os.path.abspath(os.path.realpath("Queue") + f"\song{q_num}.%(ext)s")
ydl_opts = {
'format': 'bestaudio/best',
'quiet': True,
'outtmpl': queue_path,
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
print("Downloading audio now\n")
ydl.download([carmelSongs[query]])
此代码在 windows 机器上按预期工作,但文件不会进入 linux 机器(使用 heroku 的云托管)工作目录中的队列文件夹。这是一个 discord.py 机器人,其中很多代码都来自我观看的一个 youtube 视频,我在其中调整了代码以满足我的需要。这是他的代码中我不完全理解的部分之一,因此非常感谢任何帮助!
我有一个没有return任何东西的测试机制:
@client.command()
async def troubleshoot(ctx):
for item in os.listdir("Queue"):
print(item)
再一次,我们将不胜感激。
我非常确定这是主要问题,因为所有其他方面都运行良好。
感谢 @peeol,我能够根据 linux 标准将脚本中的所有反斜杠更改为正斜杠。
queue_path = os.path.abspath(os.path.realpath("Queue") + f"\song{q_num}.%(ext)s")
ydl_opts = {
'format': 'bestaudio/best',
'quiet': True,
'outtmpl': queue_path,
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
print("Downloading audio now\n")
ydl.download([carmelSongs[query]])
此代码在 windows 机器上按预期工作,但文件不会进入 linux 机器(使用 heroku 的云托管)工作目录中的队列文件夹。这是一个 discord.py 机器人,其中很多代码都来自我观看的一个 youtube 视频,我在其中调整了代码以满足我的需要。这是他的代码中我不完全理解的部分之一,因此非常感谢任何帮助!
我有一个没有return任何东西的测试机制:
@client.command()
async def troubleshoot(ctx):
for item in os.listdir("Queue"):
print(item)
再一次,我们将不胜感激。 我非常确定这是主要问题,因为所有其他方面都运行良好。
感谢 @peeol,我能够根据 linux 标准将脚本中的所有反斜杠更改为正斜杠。