aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/common.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-09-16 00:51:40 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-09-16 01:28:55 +0530
commit0001fcb586c3ab297cd48c77ddd6f5d40546dac4 (patch)
treecddeb81eba7987e3cc22e8b631a47f8fb1145941 /yt_dlp/extractor/common.py
parentc589c1d3956cb9a8655e8555f2e02f14fbca8a2e (diff)
downloadhypervideo-pre-0001fcb586c3ab297cd48c77ddd6f5d40546dac4.tar.lz
hypervideo-pre-0001fcb586c3ab297cd48c77ddd6f5d40546dac4.tar.xz
hypervideo-pre-0001fcb586c3ab297cd48c77ddd6f5d40546dac4.zip
Add option `--netrc-location`
Closes #792, #963
Diffstat (limited to 'yt_dlp/extractor/common.py')
-rw-r--r--yt_dlp/extractor/common.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py
index 54a9dc263..e79684231 100644
--- a/yt_dlp/extractor/common.py
+++ b/yt_dlp/extractor/common.py
@@ -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]