Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
cleanup how parsed args are handled in system
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules-WinnfieldX committed Jan 4, 2024
1 parent ae0d168 commit f4ce71d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cyberdrop_dl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.1.33"
__version__ = "5.1.34"
6 changes: 4 additions & 2 deletions cyberdrop_dl/managers/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ async def async_startup(self) -> None:
self.download_manager = DownloadManager(self)
self.progress_manager = ProgressManager(self)

# set files from args

from cyberdrop_dl.utils.utilities import MAX_NAME_LENGTHS
MAX_NAME_LENGTHS['FILE'] = int(self.config_manager.global_settings_data['General']['max_file_name_length'])
MAX_NAME_LENGTHS['FOLDER'] = int(self.config_manager.global_settings_data['General']['max_folder_name_length'])
Expand Down Expand Up @@ -159,8 +161,8 @@ async def args_logging(self) -> None:
print_settings["Logs"]["log_folder"] = str(print_settings["Logs"]["log_folder"])
print_settings['Sorting']['sort_folder'] = str(print_settings['Sorting']['sort_folder'])

input_file = str(self.config_manager.settings_data['Files']['input_file']) if not self.args_manager.input_file else str(self.args_manager.input_file)
download_dir = str(self.config_manager.settings_data['Files']['download_folder']) if not self.args_manager.download_dir else str(self.args_manager.download_dir)
input_file = str(self.path_manager.input_file)
download_dir = str(self.path_manager.download_dir)

await log(f"Starting Cyberdrop-DL Process for {self.config_manager.loaded_config} Config", 10)
await log(f"Running version {__version__}", 10)
Expand Down
6 changes: 3 additions & 3 deletions cyberdrop_dl/managers/path_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ def pre_startup(self) -> None:

def startup(self) -> None:
"""Startup process for the Directory Manager"""
self.download_dir = self.manager.config_manager.settings_data['Files']['download_folder']
self.download_dir = self.manager.config_manager.settings_data['Files']['download_folder'] if not self.manager.args_manager.download_dir else self.manager.args_manager.download_dir
self.sorted_dir = self.manager.config_manager.settings_data['Sorting']['sort_folder']
self.log_dir = self.manager.config_manager.settings_data['Logs']['log_folder'] if not self.manager.args_manager.log_dir else self.manager.args_manager.log_dir
self.input_file = self.manager.config_manager.settings_data['Files']['input_file']
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']
Expand All @@ -61,6 +61,6 @@ def startup(self) -> None:
self.scrape_error_log = self.log_dir / self.manager.config_manager.settings_data['Logs']['scrape_error_urls_filename']

self.log_dir.mkdir(parents=True, exist_ok=True)
if not self.input_file.is_file() and not self.manager.args_manager.input_file:
if not self.input_file.is_file():
self.input_file.touch(exist_ok=True)
self.history_db.touch(exist_ok=True)
2 changes: 0 additions & 2 deletions cyberdrop_dl/scraper/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ async def regex_links(self, line: str) -> List:
async def load_links(self) -> None:
"""Loads links from args / input file"""
input_file = self.manager.path_manager.input_file
if self.manager.args_manager.input_file:
input_file = Path(self.manager.args_manager.input_file)

links = []
if not self.manager.args_manager.other_links:
Expand Down
2 changes: 0 additions & 2 deletions cyberdrop_dl/utils/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ async def get_filename_and_ext(filename: str, forum: bool = False) -> Tuple[str,
async def get_download_path(manager: Manager, scrape_item: ScrapeItem, domain: str) -> Path:
"""Returns the path to the download folder"""
download_dir = manager.path_manager.download_dir
if manager.args_manager.download_dir:
download_dir = Path(manager.args_manager.download_dir)

if scrape_item.retry:
return scrape_item.retry_path
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cyberdrop-dl"
version = "5.1.33"
version = "5.1.34"
description = "Bulk downloader for multiple file hosts"
authors = ["Jules Winnfield <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit f4ce71d

Please sign in to comment.