mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-01-03 18:10:10 +09:00
[YoutubeDL] improvements to warn_if_short_id()
This commit is contained in:
parent
a803582717
commit
cffb95942a
@ -437,11 +437,11 @@ class YoutubeDL(object):
|
|||||||
|
|
||||||
register_socks_protocols()
|
register_socks_protocols()
|
||||||
|
|
||||||
def warn_if_short_id(self, argv):
|
def warn_if_short_id(self, argv, parser):
|
||||||
# short YouTube ID starting with dash?
|
# short YouTube ID starting with dash?
|
||||||
idxs = [
|
idxs = [
|
||||||
i for i, a in enumerate(argv)
|
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:
|
if idxs:
|
||||||
correct_argv = (
|
correct_argv = (
|
||||||
['youtube-dl']
|
['youtube-dl']
|
||||||
|
@ -13,6 +13,7 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
from .options import (
|
from .options import (
|
||||||
|
_hide_login_info,
|
||||||
parseOpts,
|
parseOpts,
|
||||||
)
|
)
|
||||||
from .compat import (
|
from .compat import (
|
||||||
@ -453,7 +454,7 @@ def _real_main(argv=None):
|
|||||||
if opts.update_self or opts.rm_cachedir:
|
if opts.update_self or opts.rm_cachedir:
|
||||||
sys.exit()
|
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(
|
parser.error(
|
||||||
'You must provide at least one URL.\n'
|
'You must provide at least one URL.\n'
|
||||||
'Type youtube-dl --help to see a list of all options.')
|
'Type youtube-dl --help to see a list of all options.')
|
||||||
|
Loading…
Reference in New Issue
Block a user