如何在 youtube-dl 中设置默认下载位置 [英] how to set up default download location in youtube-dl

查看:41
本文介绍了如何在 youtube-dl 中设置默认下载位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 youtube-dl 中设置默认下载位置,以便我使用 youtube-dl 下载的所有内容都进入该默认目录?

how can I set default download location in youtube-dl so that everything that I download with youtube-dl goes into that default directory?

推荐答案

您需要在配置文件中使用 -o 开关

youtube-dl 上的输出由 --output-o 开关处理;将其作为选项传递,然后是要将下载保存到的目标:

You need to use the -o switch with the Configuration file

Output on youtube-dl is handled with the --output or -o switch; pass it as an option, followed by the destination you want to save your downloads to:

youtube-dl -o '%USERPROFILE%\Desktop\%(title)s-%(id)s.%(ext)s' www.youtube.com/link/to/video

请注意,-o 具有双重功能,因为它还使用变量为输出文件的命名方式设置了模板.在这个例子中,它会输出原始下载视频的标题,然后是文件扩展名,这是我个人的喜好.对于可以在文件名中使用的所有变量,请查看 youtube-dl此处提供文档.

Note that -o has a dual function in that it also sets a template for how your output files will be named, using variables. In this example, it will output the title of the original downloaded video followed by the file extension, which is my personal preference. For all of the variables that can be used in a filename, have a look at the youtube-dl documentation here.

youtube-dl 还允许使用配置文件 - 该文件可用于配置您最常用的开关,以便程序可以从那里提取它们相反,每次运行时都不必显式调用它们.这是您要查找的默认下载位置所需要的. 配置文件可用于设置默认输出目标,这样您就不必再次明确设置输出.

youtube-dl also allows use of a configuration file - a file that can be used to configure the switches you most frequently use so the program can pull them from there instead, saving you from having to explicitly call them each time you run it. This is what you'll need for the default download location that you're looking for. The configuration file can be used to set a default output destination so that you never have to explicitly set an output again.

要为 youtube-dl 设置配置文件,假设您有 Windows:

To set up a configuration file for youtube-dl, assuming you have Windows:

  1. %APPDATA%\Roaming 中,创建一个 youtube-dl 文件夹(如果尚不存在).

  1. In %APPDATA%\Roaming, create a youtube-dl folder if one doesn't already exist.

在该文件夹内,创建一个名为 config.txt 的纯文本文件.

Inside that folder, create a plain text file named config.txt.

youtube-dl 选项放在文件中,就像您通常在带有 youtube-dl 的命令行上使用它们一样,将每个选项放在一个新的线.例如,对于输出开关,您可以使用:-o %USERPROFILE%\Desktop.有关配置文件的更多信息,请阅读此处的文档.

Place youtube-dl options in the file as you'd normally use them on the command line with youtube-dl, placing each one on a new line. For example, for the output switch, you'd use: -o %USERPROFILE%\Desktop. For more on the Configuration file, read the documentation on it here.

覆盖配置文件

即使在配置文件中配置了一个选项,也可以通过从命令行显式调用它来覆盖它.因此,如果您在配置文件中将 -o 设置为下载的默认位置,但想要将下载保存到其他位置以用于当前作业,只需调用 -o 在命令行上将只覆盖当前程序运行的配置文件.

Overriding the Configuration file

Even when an option is configured in a configuration file, it can be overridden by calling it explicitly from the command line. So, if you have -o set in a configuration file to be the default location for downloads, but want to save downloads to somewhere else for a current job, simply calling -o on the command line will override the configuration file for the current run of the program only.

这篇关于如何在 youtube-dl 中设置默认下载位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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