A feature-rich command-line audio/video downloader
`--config-location -` to provide options interactively
pukkandan6b9e832db7de
diff --git a/README.md b/README.mdindex e71a150fd4..fbbd6f3aba 100644--- a/README.md+++ b/README.md@@ -358,8 +358,9 @@ You can also fork the project on github and run your fork's [build workflow](.gidefined 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 playlistdiff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.pyindex 66fee95cdd..12751b0092 100644--- a/yt_dlp/__init__.py+++ b/yt_dlp/__init__.py@@ -9,7 +9,7 @@ import osimport reimport sys-from .compat import compat_getpass, compat_os_name, compat_shlex_quote+from .compat import compat_getpass, compat_shlex_quotefrom .cookies import SUPPORTED_BROWSERS, SUPPORTED_KEYRINGSfrom .downloader import FileDownloaderfrom .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:diff --git a/yt_dlp/options.py b/yt_dlp/options.pyindex c0718e0073..65391410f1 100644--- a/yt_dlp/options.py+++ b/yt_dlp/options.py@@ -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,diff --git a/yt_dlp/utils.py b/yt_dlp/utils.pyindex 2e3c51562a..6701492f22 100644--- a/yt_dlp/utils.py+++ b/yt_dlp/utils.py@@ -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 = Noneparsed_args = None@@ -5188,6 +5194,9 @@ class Config:self.parsed_args, self.filename = args, filenamefor location in opts.config_locations or []:+ if location == '-':+ self.append_config(shlex.split(read_stdin('options'), comments=True), label='stdin')+ continuelocation = os.path.join(directory, expand_path(location))if os.path.isdir(location):location = os.path.join(location, 'yt-dlp.conf')