From 7f69e0c1d1f9da60dac426525baf05ef5538f44c Mon Sep 17 00:00:00 2001 From: Jules-WinnfieldX Date: Fri, 19 Apr 2024 12:53:29 -0600 Subject: [PATCH] Add more CLI args. --- cyberdrop_dl/__init__.py | 2 +- cyberdrop_dl/managers/args_manager.py | 10 +++++++++- cyberdrop_dl/managers/path_manager.py | 15 ++++++++++----- cyberdrop_dl/utils/args/args.py | 7 +++++++ pyproject.toml | 2 +- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.py index b70e8b6bd..2a201abce 100644 --- a/cyberdrop_dl/__init__.py +++ b/cyberdrop_dl/__init__.py @@ -1 +1 @@ -__version__ = "5.2.37" +__version__ = "5.2.38" diff --git a/cyberdrop_dl/managers/args_manager.py b/cyberdrop_dl/managers/args_manager.py index c63567e08..c1b339f5b 100644 --- a/cyberdrop_dl/managers/args_manager.py +++ b/cyberdrop_dl/managers/args_manager.py @@ -34,6 +34,13 @@ def __init__(self): # Sorting self.sort_downloads = field(init=False) self.sort_folder = None + + # Logs + self.main_log_filename = None + self.last_forum_post_filename = None + self.unsupported_urls_filename = None + self.download_error_urls_filename = None + self.scrape_error_urls_filename = None def startup(self) -> None: """Parses arguments and sets variables accordingly""" @@ -72,7 +79,6 @@ def startup(self) -> None: self.immediate_download = True if self.parsed_args['log_folder']: self.log_dir = Path(self.parsed_args['log_folder']) - if self.parsed_args['sort_downloads']: self.sort_downloads = True if self.parsed_args['sort_folder']: @@ -97,3 +103,5 @@ def startup(self) -> None: del self.parsed_args['log_folder'] del self.parsed_args['proxy'] del self.parsed_args['links'] + del self.parsed_args['sort_downloads'] + del self.parsed_args['sort_folder'] diff --git a/cyberdrop_dl/managers/path_manager.py b/cyberdrop_dl/managers/path_manager.py index 1e9dd243e..a21f049c7 100644 --- a/cyberdrop_dl/managers/path_manager.py +++ b/cyberdrop_dl/managers/path_manager.py @@ -54,11 +54,16 @@ def startup(self) -> None: self.input_file = self.manager.config_manager.settings_data['Files']['input_file'] if not self.manager.args_manager.input_file else self.manager.args_manager.input_file self.history_db = self.cache_dir / "cyberdrop.db" - self.main_log = self.log_dir / self.manager.config_manager.settings_data['Logs']['main_log_filename'] - self.last_post_log = self.log_dir / self.manager.config_manager.settings_data['Logs']['last_forum_post_filename'] - self.unsupported_urls_log = self.log_dir / self.manager.config_manager.settings_data['Logs']['unsupported_urls_filename'] - self.download_error_log = self.log_dir / self.manager.config_manager.settings_data['Logs']['download_error_urls_filename'] - self.scrape_error_log = self.log_dir / self.manager.config_manager.settings_data['Logs']['scrape_error_urls_filename'] + self.main_log = self.log_dir / (self.manager.config_manager.settings_data['Logs']['main_log_filename'] + if not self.manager.args_manager.main_log_filename else self.manager.args_manager.main_log_filename) + self.last_post_log = self.log_dir / (self.manager.config_manager.settings_data['Logs']['last_forum_post_filename'] + if not self.manager.args_manager.last_forum_post_filename else self.manager.args_manager.last_forum_post_filename) + self.unsupported_urls_log = self.log_dir / (self.manager.config_manager.settings_data['Logs']['unsupported_urls_filename'] + if not self.manager.args_manager.unsupported_urls_filename else self.manager.args_manager.unsupported_urls_filename) + self.download_error_log = self.log_dir / (self.manager.config_manager.settings_data['Logs']['download_error_urls_filename'] + if not self.manager.args_manager.download_error_urls_filename else self.manager.args_manager.download_error_urls_filename) + self.scrape_error_log = self.log_dir / (self.manager.config_manager.settings_data['Logs']['scrape_error_urls_filename'] + if not self.manager.args_manager.scrape_error_urls_filename else self.manager.args_manager.scrape_error_urls_filename) self.log_dir.mkdir(parents=True, exist_ok=True) if not self.input_file.is_file(): diff --git a/cyberdrop_dl/utils/args/args.py b/cyberdrop_dl/utils/args/args.py index f767ad913..31be06879 100644 --- a/cyberdrop_dl/utils/args/args.py +++ b/cyberdrop_dl/utils/args/args.py @@ -25,6 +25,11 @@ def parse_args() -> argparse.Namespace: file_paths.add_argument("--config-file", type=str, help="path to the CDL settings.yaml file to load", default="") file_paths.add_argument("--appdata-folder", type=str, help="path to where you want CDL to store it's AppData folder", default="") file_paths.add_argument("--log-folder", type=str, help="path to where you want CDL to store it's log files", default="") + file_paths.add_argument("--main-log-filename", type=str, help="filename for the main log file", default="") + file_paths.add_argument("--last-forum-post-filename", type=str, help="filename for the last forum post log file", default="") + file_paths.add_argument("--unsupported-urls-filename", type=str, help="filename for the unsupported urls log file", default="") + file_paths.add_argument("--download-error-urls-filename", type=str, help="filename for the download error urls log file", default="") + file_paths.add_argument("--scrape-error-urls-filename", type=str, help="filename for the scrape error urls log file", default="") # Settings download_options = parser.add_argument_group("Download_Options") @@ -35,6 +40,8 @@ def parse_args() -> argparse.Namespace: download_options.add_argument("--include-thread-id-in-folder-name", action="store_true", help="include thread id in folder name", default=False) download_options.add_argument("--remove-domains-from-folder-names", action="store_true", help="remove website domains from folder names", default=False) download_options.add_argument("--remove-generated-id-from-filenames", action="store_true", help="remove site generated id from filenames", default=False) + download_options.add_argument("--scrape-single-forum-post", action="store_true", help="scrape single forum post", default=False) + download_options.add_argument("--separate-posts", action="store_true", help="separate posts into folders", default=False) download_options.add_argument("--skip-download-mark-completed", action="store_true", help="skip download and mark as completed in history", default=False) file_size_limits = parser.add_argument_group("File_Size_Limits") diff --git a/pyproject.toml b/pyproject.toml index eccac3dcb..06a0cc58c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cyberdrop-dl" -version = "5.2.37" +version = "5.2.38" description = "Bulk downloader for multiple file hosts" authors = ["Jules Winnfield "] readme = "README.md"