mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 06:10:12 +01:00
parent
c589c1d395
commit
0001fcb586
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,6 +3,7 @@
|
||||||
*.spec
|
*.spec
|
||||||
cookies
|
cookies
|
||||||
*cookies.txt
|
*cookies.txt
|
||||||
|
.netrc
|
||||||
|
|
||||||
# Downloaded
|
# Downloaded
|
||||||
*.srt
|
*.srt
|
||||||
|
|
12
README.md
12
README.md
|
@ -695,6 +695,9 @@ ## Authentication Options:
|
||||||
out, yt-dlp will ask interactively
|
out, yt-dlp will ask interactively
|
||||||
-2, --twofactor TWOFACTOR Two-factor authentication code
|
-2, --twofactor TWOFACTOR Two-factor authentication code
|
||||||
-n, --netrc Use .netrc authentication data
|
-n, --netrc Use .netrc authentication data
|
||||||
|
--netrc-location PATH Location of .netrc authentication data;
|
||||||
|
either the path or its containing
|
||||||
|
directory. Defaults to ~/.netrc
|
||||||
--video-password PASSWORD Video password (vimeo, youku)
|
--video-password PASSWORD Video password (vimeo, youku)
|
||||||
--ap-mso MSO Adobe Pass multiple-system operator (TV
|
--ap-mso MSO Adobe Pass multiple-system operator (TV
|
||||||
provider) identifier, use --ap-list-mso for
|
provider) identifier, use --ap-list-mso for
|
||||||
|
@ -923,14 +926,14 @@ # Save all videos under YouTube directory in your home directory
|
||||||
|
|
||||||
### Authentication with `.netrc` file
|
### Authentication with `.netrc` file
|
||||||
|
|
||||||
You may also want to configure automatic credentials storage for extractors that support authentication (by providing login and password with `--username` and `--password`) in order not to pass credentials as command line arguments on every yt-dlp execution and prevent tracking plain text passwords in the shell command history. You can achieve this using a [`.netrc` file](https://stackoverflow.com/tags/.netrc/info) on a per extractor basis. For that you will need to create a `.netrc` file in your `$HOME` and restrict permissions to read/write by only you:
|
You may also want to configure automatic credentials storage for extractors that support authentication (by providing login and password with `--username` and `--password`) in order not to pass credentials as command line arguments on every yt-dlp execution and prevent tracking plain text passwords in the shell command history. You can achieve this using a [`.netrc` file](https://stackoverflow.com/tags/.netrc/info) on a per extractor basis. For that you will need to create a `.netrc` file in `--netrc-location` and restrict permissions to read/write by only you:
|
||||||
```
|
```
|
||||||
touch $HOME/.netrc
|
touch $HOME/.netrc
|
||||||
chmod a-rwx,u+rw $HOME/.netrc
|
chmod a-rwx,u+rw $HOME/.netrc
|
||||||
```
|
```
|
||||||
After that you can add credentials for an extractor in the following format, where *extractor* is the name of the extractor in lowercase:
|
After that you can add credentials for an extractor in the following format, where *extractor* is the name of the extractor in lowercase:
|
||||||
```
|
```
|
||||||
machine <extractor> login <login> password <password>
|
machine <extractor> login <username> password <password>
|
||||||
```
|
```
|
||||||
For example:
|
For example:
|
||||||
```
|
```
|
||||||
|
@ -939,10 +942,7 @@ ### Authentication with `.netrc` file
|
||||||
```
|
```
|
||||||
To activate authentication with the `.netrc` file you should pass `--netrc` to yt-dlp or place it in the [configuration file](#configuration).
|
To activate authentication with the `.netrc` file you should pass `--netrc` to yt-dlp or place it in the [configuration file](#configuration).
|
||||||
|
|
||||||
On Windows you may also need to setup the `%HOME%` environment variable manually. For example:
|
The default location of the .netrc file is `$HOME` (`~`) in UNIX. On Windows, it is `%HOME%` if present, `%USERPROFILE%` (generally `C:\Users\<user name>`) or `%HOMEDRIVE%%HOMEPATH%`
|
||||||
```
|
|
||||||
set HOME=%USERPROFILE%
|
|
||||||
```
|
|
||||||
|
|
||||||
# OUTPUT TEMPLATE
|
# OUTPUT TEMPLATE
|
||||||
|
|
||||||
|
|
|
@ -575,6 +575,7 @@ def report_args_compat(arg, name):
|
||||||
|
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
'usenetrc': opts.usenetrc,
|
'usenetrc': opts.usenetrc,
|
||||||
|
'netrc_location': opts.netrc_location,
|
||||||
'username': opts.username,
|
'username': opts.username,
|
||||||
'password': opts.password,
|
'password': opts.password,
|
||||||
'twofactor': opts.twofactor,
|
'twofactor': opts.twofactor,
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
compat_cookies_SimpleCookie,
|
compat_cookies_SimpleCookie,
|
||||||
compat_etree_Element,
|
compat_etree_Element,
|
||||||
compat_etree_fromstring,
|
compat_etree_fromstring,
|
||||||
|
compat_expanduser,
|
||||||
compat_getpass,
|
compat_getpass,
|
||||||
compat_http_client,
|
compat_http_client,
|
||||||
compat_os_name,
|
compat_os_name,
|
||||||
|
@ -1166,7 +1167,10 @@ def _get_netrc_login_info(self, netrc_machine=None):
|
||||||
|
|
||||||
if self.get_param('usenetrc', False):
|
if self.get_param('usenetrc', False):
|
||||||
try:
|
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:
|
if info is not None:
|
||||||
username = info[0]
|
username = info[0]
|
||||||
password = info[2]
|
password = info[2]
|
||||||
|
|
|
@ -478,6 +478,10 @@ def _dict_from_options_callback(
|
||||||
'-n', '--netrc',
|
'-n', '--netrc',
|
||||||
action='store_true', dest='usenetrc', default=False,
|
action='store_true', dest='usenetrc', default=False,
|
||||||
help='Use .netrc authentication data')
|
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(
|
authentication.add_option(
|
||||||
'--video-password',
|
'--video-password',
|
||||||
dest='videopassword', metavar='PASSWORD',
|
dest='videopassword', metavar='PASSWORD',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user