From cffb95942ab54474a054fa0c9ecc18131633288e Mon Sep 17 00:00:00 2001 From: kikuyan Date: Sun, 4 Jul 2021 02:59:31 +0900 Subject: [PATCH] [YoutubeDL] improvements to warn_if_short_id() --- youtube_dl/YoutubeDL.py | 4 ++-- youtube_dl/__init__.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index fe30758ef..12bac53ca 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -437,11 +437,11 @@ class YoutubeDL(object): register_socks_protocols() - def warn_if_short_id(self, argv): + def warn_if_short_id(self, argv, parser): # short YouTube ID starting with dash? idxs = [ i for i, a in enumerate(argv) - if re.match(r'^-[0-9A-Za-z_-]{10}$', a)] + if re.match(r'^-[0-9A-Za-z_-]{10}$', a) and not parser.has_option(a)] if idxs: correct_argv = ( ['youtube-dl'] diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index e1bd67919..235f0d39c 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -13,6 +13,7 @@ import sys from .options import ( + _hide_login_info, parseOpts, ) from .compat import ( @@ -453,7 +454,7 @@ def _real_main(argv=None): if opts.update_self or opts.rm_cachedir: sys.exit() - ydl.warn_if_short_id(sys.argv[1:] if argv is None else argv) + ydl.warn_if_short_id(_hide_login_info(sys.argv[1:] if argv is None else argv), parser) parser.error( 'You must provide at least one URL.\n' 'Type youtube-dl --help to see a list of all options.')