mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-02-04 13:07:00 +00:00
@@ -575,6 +575,7 @@ def _real_main(argv=None):
|
||||
|
||||
ydl_opts = {
|
||||
'usenetrc': opts.usenetrc,
|
||||
'netrc_location': opts.netrc_location,
|
||||
'username': opts.username,
|
||||
'password': opts.password,
|
||||
'twofactor': opts.twofactor,
|
||||
|
||||
@@ -18,6 +18,7 @@ from ..compat import (
|
||||
compat_cookies_SimpleCookie,
|
||||
compat_etree_Element,
|
||||
compat_etree_fromstring,
|
||||
compat_expanduser,
|
||||
compat_getpass,
|
||||
compat_http_client,
|
||||
compat_os_name,
|
||||
@@ -1166,7 +1167,10 @@ class InfoExtractor(object):
|
||||
|
||||
if self.get_param('usenetrc', False):
|
||||
try:
|
||||
info = netrc.netrc().authenticators(netrc_machine)
|
||||
netrc_file = compat_expanduser(self.get_param('netrc_location') or '~')
|
||||
if os.path.isdir(netrc_file):
|
||||
netrc_file = os.path.join(netrc_file, '.netrc')
|
||||
info = netrc.netrc(file=netrc_file).authenticators(netrc_machine)
|
||||
if info is not None:
|
||||
username = info[0]
|
||||
password = info[2]
|
||||
|
||||
@@ -478,6 +478,10 @@ def parseOpts(overrideArguments=None):
|
||||
'-n', '--netrc',
|
||||
action='store_true', dest='usenetrc', default=False,
|
||||
help='Use .netrc authentication data')
|
||||
authentication.add_option(
|
||||
'--netrc-location',
|
||||
dest='netrc_location', metavar='PATH',
|
||||
help='Location of .netrc authentication data; either the path or its containing directory. Defaults to ~/.netrc')
|
||||
authentication.add_option(
|
||||
'--video-password',
|
||||
dest='videopassword', metavar='PASSWORD',
|
||||
|
||||
Reference in New Issue
Block a user