如何在 python 中使用 youtube-dl 在 ydl_opts 中设置目录? [英] how to set directory in ydl_opts in using youtube-dl in python?

查看:135
本文介绍了如何在 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',

这篇关于如何在 python 中使用 youtube-dl 在 ydl_opts 中设置目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆