1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-01-26 17:32:51 +08:00

Support using the short option name in the INI configuration files

This commit is contained in:
Jaime Marquínez Ferrándiz 2016-04-01 20:50:35 +02:00
parent 479181e3a6
commit 648f889551
2 changed files with 3 additions and 3 deletions

View File

@ -431,12 +431,12 @@ You can use `--ignore-config` if you want to disable the configuration file for
In addition to globally setting options, you can also set different options for each extractor. In addition to globally setting options, you can also set different options for each extractor.
A different set of files is used: `~/.config/youtube-dl/config.ini` and `/etc/youtube-dl.ini` on Unix, `%APPDATA%\youtube-dl\config.ini` or `C:\Users\<user name>\youtube-dl.ini` on Windows. A different set of files is used: `~/.config/youtube-dl/config.ini` and `/etc/youtube-dl.ini` on Unix, `%APPDATA%\youtube-dl\config.ini` or `C:\Users\<user name>\youtube-dl.ini` on Windows.
The files are stored in the [INI format](https://en.wikipedia.org/wiki/INI_file), each argument must be written in its own line using its full name without the leading `--`. The files are stored in the [INI format](https://en.wikipedia.org/wiki/INI_file), each argument must be written in its own line using its full name without the leading `--` or the short version without the leading `-`.
To start a section with the options for an specific extractor you can write a line in the form `[<name>]`, where `<name>` is the name printed before the info message while downloading (like `youtube`, `youtube:playlist`, `vimeo` ...). To start a section with the options for an specific extractor you can write a line in the form `[<name>]`, where `<name>` is the name printed before the info message while downloading (like `youtube`, `youtube:playlist`, `vimeo` ...).
For example, with the following configuration file youtube-dl will always extract the audio, as an mp3 file for YouTube videos and if the are inside a playlist they will be saved in a different folder: For example, with the following configuration file youtube-dl will always extract the audio, as an mp3 file for YouTube videos and if the are inside a playlist they will be saved in a different folder:
``` ```
extract-audio= x=
[youtube] [youtube]
audio-format=mp3 audio-format=mp3

View File

@ -756,7 +756,7 @@ def parseOpts(overrideArguments=None):
def convert_opts(opts): def convert_opts(opts):
return [ return [
'--' + opt + ('' if not arg else ('=' + arg)) ('-' if len(opt) == 1 else '--') + opt + ('' if not arg else ('=' + arg))
for opt, arg in opts] for opt, arg in opts]
global_opts = convert_opts(parser.items('@GLOBAL@')) global_opts = convert_opts(parser.items('@GLOBAL@'))
section_opts = dict((section, convert_opts(parser.items(section))) for section in parser.sections() if section != '@GLOBAL@') section_opts = dict((section, convert_opts(parser.items(section))) for section in parser.sections() if section != '@GLOBAL@')