Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
fix: only print dedupe stats (menu option) (#1064)
NTFSvolume9988237e4350
diff --git a/cyberdrop_dl/clients/hash_client.py b/cyberdrop_dl/clients/hash_client.pyindex 6b7a7c856..1974fd474 100644--- a/cyberdrop_dl/clients/hash_client.py+++ b/cyberdrop_dl/clients/hash_client.py@@ -1,7 +1,6 @@from __future__ import annotationsimport asyncio-import timefrom collections import defaultdictfrom pathlib import Pathfrom typing import TYPE_CHECKING@@ -26,11 +25,10 @@ def hash_directory_scanner(manager: Manager, path: Path) -> None:enter_to_continue()-async def _hash_directory_scanner_helper(manager: Manager, path: Path):- start_time = time.perf_counter()+async def _hash_directory_scanner_helper(manager: Manager, path: Path) -> None:await manager.async_db_hash_startup()await manager.hash_manager.hash_client.hash_directory(path)- manager.progress_manager.print_stats(start_time)+ manager.progress_manager.print_dedupe_stats()await manager.async_db_close()diff --git a/cyberdrop_dl/managers/progress_manager.py b/cyberdrop_dl/managers/progress_manager.pyindex e377f047a..e23765634 100644--- a/cyberdrop_dl/managers/progress_manager.py+++ b/cyberdrop_dl/managers/progress_manager.py@@ -170,11 +170,7 @@ class ProgressManager:log_yellow(f" Sent to Jdownloader: {self.scrape_stats_progress.sent_to_jdownloader:,}")log_yellow(f" Skipped: {self.scrape_stats_progress.unsupported_urls_skipped:,}")- log_spacer(20, "")- log_cyan("Dupe Stats:")- log_yellow(f" Newly Hashed: {self.hash_progress.hashed_files:,} files")- log_yellow(f" Previously Hashed: {self.hash_progress.prev_hashed_files:,} files")- log_yellow(f" Removed (Downloads): {self.hash_progress.removed_files:,} files")+ self.print_dedupe_stats()log_spacer(20, "")log_cyan("Sort Stats:")@@ -186,6 +182,13 @@ class ProgressManager:last_padding = log_failures(self.scrape_stats_progress.return_totals(), "Scrape Failures:")log_failures(self.download_stats_progress.return_totals(), "Download Failures:", last_padding)+ def print_dedupe_stats(self) -> None:+ log_spacer(20, "")+ log_cyan("Dupe Stats:")+ log_yellow(f" Newly Hashed: {self.hash_progress.hashed_files:,} files")+ log_yellow(f" Previously Hashed: {self.hash_progress.prev_hashed_files:,} files")+ log_yellow(f" Removed (Downloads): {self.hash_progress.removed_files:,} files")+def log_failures(failures: list[UiFailureTotal], title: str = "Failures:", last_padding: int = 0) -> int:log_spacer(20, "")diff --git a/cyberdrop_dl/ui/program_ui.py b/cyberdrop_dl/ui/program_ui.pyindex 22c400090..c02e7a043 100644--- a/cyberdrop_dl/ui/program_ui.py+++ b/cyberdrop_dl/ui/program_ui.py@@ -97,7 +97,7 @@ class ProgramUI:def _scan_and_create_hashes(self) -> None:"""Scans a folder and creates hashes for all of its files."""- path = ask_dir_path("Select the directory to scan")+ path = ask_dir_path("Select the directory to scan", default=str(self.manager.path_manager.download_folder))hash_directory_scanner(self.manager, path)def _sort_files(self) -> None:diff --git a/cyberdrop_dl/ui/prompts/basic_prompts.py b/cyberdrop_dl/ui/prompts/basic_prompts.pyindex f471015fb..3fc4a155c 100644--- a/cyberdrop_dl/ui/prompts/basic_prompts.py+++ b/cyberdrop_dl/ui/prompts/basic_prompts.py@@ -52,21 +52,19 @@ def ask_choice_fuzzy(choices: list[Choice], message: str, validate_empty: bool =def ask_path(message: str = "Select path", *, validator_options: dict | None = None, **kwargs) -> Path:- options = DEFAULT_OPTIONS | kwargs+ options = DEFAULT_OPTIONS | {"default": str(Path.home())} | kwargsreturn Path(- inquirer.filepath(- message=message, default=str(Path.home()), validate=PathValidator(**(validator_options or {})), **options- ).execute()+ inquirer.filepath(message=message, validate=PathValidator(**(validator_options or {})), **options).execute())-def ask_file_path(message: str = "Select file path", **kwargs):+def ask_file_path(message: str = "Select file path", **kwargs) -> Path:options = DEFAULT_OPTIONS | kwargsvalidator_options = {"is_file": True, "message": "Input is not a file"}return ask_path(message, validator_options=validator_options, **options)-def ask_dir_path(message: str = "Select dir path", **kwargs):+def ask_dir_path(message: str = "Select dir path", **kwargs) -> Path:options = DEFAULT_OPTIONS | kwargsvalidator_options = {"is_dir": True, "message": "Input is not a directory"}return ask_path(message, validator_options=validator_options, **options)