diff --git a/docs/configuration.rst b/docs/configuration.rst index eb263c17..546ab189 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -379,7 +379,7 @@ Description The username and password to use when attempting to log in to another site. - Specifying a username and password is required for + Specifying username and password is required for * ``nijie`` @@ -415,6 +415,10 @@ Description (*) The password value for these sites should be the API key found in your user profile, not the actual account password. + Note: Leave the ``password`` value empty or undefined + to get prompted for a passeword when performing a login + (see `getpass() `__). + extractor.*.netrc ----------------- diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py index f3784272..bf4de4d4 100644 --- a/gallery_dl/extractor/common.py +++ b/gallery_dl/extractor/common.py @@ -233,7 +233,7 @@ class Extractor(): password = None if username: - password = self.config("password") + password = self.config("password") or util.LazyPrompt() elif self.config("netrc", False): try: info = netrc.netrc().authenticators(self.category) diff --git a/gallery_dl/util.py b/gallery_dl/util.py index 62aa12da..2fbba3ce 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -14,6 +14,7 @@ import sys import json import time import random +import getpass import hashlib import sqlite3 import binascii @@ -487,6 +488,13 @@ CODES = { } +class LazyPrompt(): + __slots__ = () + + def __str__(self): + return getpass.getpass() + + class CustomNone(): """None-style type that supports more operations than regular None""" __slots__ = ()