【发布时间】:2021-04-26 00:14:37
【问题描述】:
我正在尝试构建一个不和谐的音乐机器人,并正在使用 youtube_dl 下载歌曲。我想将它们保存在一个目录中,这样我就不必每次都重新下载它们。但我想更改目录中的歌曲名称。
我知道我必须更改 outtmpl 中的某些内容,但这只是给了我这首歌的 youtube 名称:
ydl_opts = {
'outtmpl': f'./project/audio/%(title)s.%(ext)s', #Output directory
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
当我将 outtmpl 替换为:'outtmpl':f'./project/audio/{songname}', 时,它给了我错误消息:
下载错误:错误:音频转换失败:文件:mp3:无效参数
【问题讨论】:
标签: python discord.py youtube-dl