如何在 python 中使用 youtube-dl 在 ydl_opts 中设置目录?

问题描述:

**

我需要添加什么来指定所有下载的mp3都将转到此目录:e:/python/downloadedsongs

What do i need to add to specify that all the download mp3 will go to this directory: e:/python/downloadedsongs

ydl_opts = {
    'format': 'bestaudio/best',
    'download_archive': 'downloaded_songs.txt',
    'outtmpl': '%(title)s.%(ext)s',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '192',
        }],
    'logger': MyLogger(),
    'progress_hooks': [my_hook],

}

如果我理解正确,outtmpl 是用于输出文件名称的模板.**

if i understand it correctly outtmpl is for the template of the name of output file. **

outtmpl可以包含目录名,简单设置

outtmpl can contain directory names, simply set

'outtmpl': 'e:/python/downloadedsongs/%(title)s.%(ext)s',