From 267d9e505bb11a2675919b3a83a13dfc942a501e Mon Sep 17 00:00:00 2001 From: Soxoj Date: Sat, 6 Nov 2021 14:29:56 +0300 Subject: [PATCH] New config options added --- docs/source/command-line-options.rst | 4 ++++ maigret/maigret.py | 12 ++++++------ maigret/resources/settings.json | 13 ++++++++++++- maigret/settings.py | 12 ++++++++++++ 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/docs/source/command-line-options.rst b/docs/source/command-line-options.rst index 44dcd8f..c6f4bcd 100644 --- a/docs/source/command-line-options.rst +++ b/docs/source/command-line-options.rst @@ -23,6 +23,10 @@ extracted username and ids. :doc:`Examples `. Main options ------------ +======= +Options are also configurable through settings files, see +:doc:`settings section `. + ``--tags`` - Filter sites for searching by tags: sites categories and two-letter country codes. E.g. photo, dating, sport; jp, us, global. Multiple tags can be associated with one site. **Warning: tags markup is diff --git a/maigret/maigret.py b/maigret/maigret.py index 515fffa..ae82114 100755 --- a/maigret/maigret.py +++ b/maigret/maigret.py @@ -204,7 +204,7 @@ def setup_arguments_parser(settings: Settings): "--cookies-jar-file", metavar="COOKIE_FILE", dest="cookie_file", - default=None, + default=settings.cookie_jar_file, help="File with cookies.", ) parser.add_argument( @@ -212,7 +212,7 @@ def setup_arguments_parser(settings: Settings): action="append", metavar='IGNORED_IDS', dest="ignore_ids_list", - default=[], + default=settings.ignore_ids_list, help="Do not make search by the specified username or other ids.", ) # reports options @@ -220,7 +220,7 @@ def setup_arguments_parser(settings: Settings): "--folderoutput", "-fo", dest="folderoutput", - default="reports", + default=settings.reports_path, metavar="PATH", help="If using multiple usernames, the output of the results will be saved to this folder.", ) @@ -230,21 +230,21 @@ def setup_arguments_parser(settings: Settings): metavar='PROXY_URL', action="store", dest="proxy", - default=None, + default=settings.proxy_url, help="Make requests over a proxy. e.g. socks5://127.0.0.1:1080", ) parser.add_argument( "--tor-proxy", metavar='TOR_PROXY_URL', action="store", - default='socks5://127.0.0.1:9050', + default=settings.tor_proxy_url, help="Specify URL of your Tor gateway. Default is socks5://127.0.0.1:9050", ) parser.add_argument( "--i2p-proxy", metavar='I2P_PROXY_URL', action="store", - default='http://127.0.0.1:4444', + default=settings.i2p_proxy_url, help="Specify URL of your I2P gateway. Default is http://127.0.0.1:4444", ) parser.add_argument( diff --git a/maigret/resources/settings.json b/maigret/resources/settings.json index e395855..88974b2 100644 --- a/maigret/resources/settings.json +++ b/maigret/resources/settings.json @@ -15,5 +15,16 @@ "supposed_usernames": [ "alex", "god", "admin", "red", "blue", "john" ], - "retries_count": 1 + "retries_count": 1, + "sites_db_path": "resources/data.json", + "timeout": 30, + "max_connections": 100, + "recursive_search": true, + "info_extracting": true, + "cookie_jar_file": null, + "ignore_ids_list": [], + "reports_path": "reports", + "proxy_url": null, + "tor_proxy_url": "socks5://127.0.0.1:9050", + "i2p_proxy_url": "http://127.0.0.1:4444" } \ No newline at end of file diff --git a/maigret/settings.py b/maigret/settings.py index 0f6fd77..1ab2fd7 100644 --- a/maigret/settings.py +++ b/maigret/settings.py @@ -1,6 +1,7 @@ import os import os.path as path import json +from typing import List SETTINGS_FILES_PATHS = [ path.join(path.dirname(path.realpath(__file__)), "resources/settings.json"), @@ -12,6 +13,17 @@ SETTINGS_FILES_PATHS = [ class Settings: # main maigret setting retries_count: int + sites_db_path: str + timeout: int + max_connections: int + recursive_search: bool + info_extracting: bool + cookie_jar_file: str + ignore_ids_list: List + reports_path: str + proxy_url: str + tor_proxy_url: str + i2p_proxy_url: str # submit mode settings presence_strings: list