From c800598cd1a3467e53b479c5efc8c6d603d94e5c Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sat, 25 Jun 2022 08:38:52 +0530 Subject: [PATCH] [options] Fix `parse_known_args` for `--` Closes #4167 --- yt_dlp/options.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/yt_dlp/options.py b/yt_dlp/options.py index a4f8e0959..8c9a9bbb4 100644 --- a/yt_dlp/options.py +++ b/yt_dlp/options.py @@ -176,8 +176,19 @@ def parse_known_args(self, args=None, values=None, strict=True): self.rargs, self.largs = self._get_args(args), [] self.values = values or self.get_default_values() while self.rargs: + arg = self.rargs[0] try: - self._process_args(self.largs, self.rargs, self.values) + if arg == '--': + del self.rargs[0] + break + elif arg.startswith('--'): + self._process_long_opt(self.rargs, self.values) + elif arg.startswith('-') and arg != '-': + self._process_short_opts(self.rargs, self.values) + elif self.allow_interspersed_args: + self.largs.append(self.rargs.pop(0)) + else: + break except optparse.OptParseError as err: if isinstance(err, self._UNKNOWN_OPTION): self.largs.append(err.opt_str)