1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-09-03 16:45:17 +00:00

Add option --netrc-location

Closes #792, #963
This commit is contained in:
pukkandan
2021-09-16 00:51:40 +05:30
parent c589c1d395
commit 0001fcb586
5 changed files with 17 additions and 7 deletions

View File

@ -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]