mirror of https://github.com/yt-dlp/yt-dlp.git
`--config-location -` to provide options interactively
This commit is contained in:
parent
d2ff2c91bb
commit
6b9e832db7
|
@ -358,8 +358,9 @@ You can also fork the project on github and run your fork's [build workflow](.gi
|
|||
defined in the current file
|
||||
--config-locations PATH Location of the main configuration file;
|
||||
either the path to the config or its
|
||||
containing directory. Can be used multiple
|
||||
times and inside other configuration files
|
||||
containing directory ("-" for stdin). Can be
|
||||
used multiple times and inside other
|
||||
configuration files
|
||||
--flat-playlist Do not extract the videos of a playlist,
|
||||
only list them
|
||||
--no-flat-playlist Extract the videos of a playlist
|
||||
|
|
|
@ -9,7 +9,7 @@ import os
|
|||
import re
|
||||
import sys
|
||||
|
||||
from .compat import compat_getpass, compat_os_name, compat_shlex_quote
|
||||
from .compat import compat_getpass, compat_shlex_quote
|
||||
from .cookies import SUPPORTED_BROWSERS, SUPPORTED_KEYRINGS
|
||||
from .downloader import FileDownloader
|
||||
from .extractor import GenericIE, list_extractor_classes
|
||||
|
@ -42,6 +42,7 @@ from .utils import (
|
|||
parse_duration,
|
||||
preferredencoding,
|
||||
read_batch_urls,
|
||||
read_stdin,
|
||||
render_table,
|
||||
setproctitle,
|
||||
std_headers,
|
||||
|
@ -63,14 +64,9 @@ def get_urls(urls, batchfile, verbose):
|
|||
batch_urls = []
|
||||
if batchfile is not None:
|
||||
try:
|
||||
if batchfile == '-':
|
||||
write_string('Reading URLs from stdin - EOF (%s) to end:\n' % (
|
||||
'Ctrl+Z' if compat_os_name == 'nt' else 'Ctrl+D'))
|
||||
batchfd = sys.stdin
|
||||
else:
|
||||
batchfd = open(
|
||||
expand_path(batchfile), encoding='utf-8', errors='ignore')
|
||||
batch_urls = read_batch_urls(batchfd)
|
||||
batch_urls = read_batch_urls(
|
||||
read_stdin('URLs') if batchfile == '-'
|
||||
else open(expand_path(batchfile), encoding='utf-8', errors='ignore'))
|
||||
if verbose:
|
||||
write_string('[debug] Batch file urls: ' + repr(batch_urls) + '\n')
|
||||
except OSError:
|
||||
|
|
|
@ -366,8 +366,8 @@ def create_parser():
|
|||
'--config-locations',
|
||||
dest='config_locations', metavar='PATH', action='append',
|
||||
help=(
|
||||
'Location of the main configuration file; either the path to the config or its containing directory. '
|
||||
'Can be used multiple times and inside other configuration files'))
|
||||
'Location of the main configuration file; either the path to the config or its containing directory '
|
||||
'("-" for stdin). Can be used multiple times and inside other configuration files'))
|
||||
general.add_option(
|
||||
'--flat-playlist',
|
||||
action='store_const', dest='extract_flat', const='in_playlist', default=False,
|
||||
|
|
|
@ -5163,6 +5163,12 @@ def parse_http_range(range):
|
|||
return int(crg.group(1)), int_or_none(crg.group(2)), int_or_none(crg.group(3))
|
||||
|
||||
|
||||
def read_stdin(what):
|
||||
eof = 'Ctrl+Z' if compat_os_name == 'nt' else 'Ctrl+D'
|
||||
write_string(f'Reading {what} from STDIN - EOF ({eof}) to end:\n')
|
||||
return sys.stdin
|
||||
|
||||
|
||||
class Config:
|
||||
own_args = None
|
||||
parsed_args = None
|
||||
|
@ -5188,6 +5194,9 @@ class Config:
|
|||
self.parsed_args, self.filename = args, filename
|
||||
|
||||
for location in opts.config_locations or []:
|
||||
if location == '-':
|
||||
self.append_config(shlex.split(read_stdin('options'), comments=True), label='stdin')
|
||||
continue
|
||||
location = os.path.join(directory, expand_path(location))
|
||||
if os.path.isdir(location):
|
||||
location = os.path.join(location, 'yt-dlp.conf')
|
||||
|
|
Loading…
Reference in New Issue