如何在 python 中使用 youtube-dl 在 ydl_opts 中设置目录?
how to set directory in ydl_opts in using youtube-dl in python?
**
我需要添加什么来指定所有下载的mp3都到这个目录: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是输出文件名的模板。
**
outtmpl可以包含目录名,只需设置
'outtmpl': 'e:/python/downloadedsongs/%(title)s.%(ext)s',
**
我需要添加什么来指定所有下载的mp3都到这个目录: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是输出文件名的模板。 **
outtmpl可以包含目录名,只需设置
'outtmpl': 'e:/python/downloadedsongs/%(title)s.%(ext)s',