1
0
Fork 0
mirror of synced 2024-06-29 03:21:19 +12:00

Merge branch 'r-pufky-config-flag'

This commit is contained in:
Ali Parlakci 2021-03-27 12:28:39 +03:00
commit 3ac4ac3f3d
3 changed files with 34 additions and 11 deletions

View file

@ -187,6 +187,15 @@ Example usage: **`--downloaded-posts D:\bdfr\ALL_POSTS.txt`**
## **`--downloaded-delay`**
When specified, it delays every download for given seconds.
## **`--config`**
Specify a `config.json` file to use. This will disable reading from the default `Bulk downloader for reddit/config.json` file, as well as `--use-local-config` option.
Example usage: **`--config /etc/bdfr/config.json`**
Example usage: **`-c ~/config.json`**
Example usage: **`--config c:\Users\Me\Downloads\config.json`**
Example usage: **`-c c:\config.json`**
## ❔ FAQ
### I am running the script on a headless machine or on a remote server. How can I authenticate my reddit account?

View file

@ -268,15 +268,27 @@ def printLogo():
f"https://github.com/aliparlakci/bulk-downloader-for-reddit/\n"
)
def main():
sys.argv = sys.argv + GLOBAL.config["options"].split()
arguments = Arguments.parse()
GLOBAL.arguments = arguments
if Path("config.json").exists():
GLOBAL.configDirectory = Path("config.json")
if arguments.config:
if arguments.use_local_config:
sys.exit()
if Path(arguments.config).exists():
GLOBAL.configDirectory = Path(arguments.config)
else:
VanillaPrint("custom config",arguments.config,"not found. Exiting.")
sys.exit()
else:
if not Path(GLOBAL.defaultConfigDirectory).is_dir():
os.makedirs(GLOBAL.defaultConfigDirectory)
GLOBAL.configDirectory = GLOBAL.defaultConfigDirectory / "config.json"
if Path("config.json").exists():
GLOBAL.configDirectory = Path("config.json")
else:
if not Path(GLOBAL.defaultConfigDirectory).is_dir():
os.makedirs(GLOBAL.defaultConfigDirectory)
GLOBAL.configDirectory = GLOBAL.defaultConfigDirectory / "config.json"
try:
GLOBAL.config = Config(GLOBAL.configDirectory).generate()
except InvalidJSONFile as exception:
@ -285,11 +297,6 @@ def main():
input("\nPress enter to quit")
sys.exit()
sys.argv = sys.argv + GLOBAL.config["options"].split()
arguments = Arguments.parse()
GLOBAL.arguments = arguments
if arguments.set_filename:
Config(GLOBAL.configDirectory).setCustomFileName()
sys.exit()

View file

@ -169,6 +169,13 @@ class Arguments:
metavar="DELAY",
type=int,
help="Amount, in seconds, to delay before beginning the next item in the download queue")
parser.add_argument(
"--config","-c",
help="Specify exact config.json file to use. " \
"Disables reading from 'Bulk downloader for " \
"reddit/config.json' and --use-local-config " \
"option.")
if arguments == []:
return parser.parse_args()