Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
fix: handle paths with special characters (stats hyperlinks) (#792)
NTFSvolumeb4e9ce2c1dd5
diff --git a/cyberdrop_dl/managers/progress_manager.py b/cyberdrop_dl/managers/progress_manager.pyindex 2263abe3f..2f57e10d2 100644--- a/cyberdrop_dl/managers/progress_manager.py+++ b/cyberdrop_dl/managers/progress_manager.py@@ -12,6 +12,8 @@ from rich.columns import Columnsfrom rich.console import Groupfrom rich.layout import Layoutfrom rich.progress import Progress, SpinnerColumn, TaskID, TextColumn+from rich.text import Text+from yarl import URLfrom cyberdrop_dl.ui.progress.downloads_progress import DownloadsProgressfrom cyberdrop_dl.ui.progress.file_progress import FileProgress@@ -131,11 +133,12 @@ class ProgressManager:config_path_text = get_console_hyperlink(config_path, text=self.manager.config_manager.loaded_config)input_file_text = get_input(self.manager)log_folder_text = get_console_hyperlink(self.manager.path_manager.log_folder)- log_cyan(f"Run Stats (config: {config_path_text}):", markup=True)- log_yellow(f" Log Folder: {log_folder_text}", markup=True)- log_yellow(f" Input File: {input_file_text}", markup=True)++ log_concat("Run Stats (config: ", config_path_text, ")", style="cyan")+ log_concat(" Input File: ", input_file_text, style="yellow")log_yellow(f" Input URLs: {self.manager.scrape_mapper.count:,}")log_yellow(f" Input URL Groups: {self.manager.scrape_mapper.group_count:,}")+ log_concat(" Log Folder: ", log_folder_text, style="yellow")log_yellow(f" Total Runtime: {runtime}")log_yellow(f" Total Downloaded Data: {data_size}")@@ -184,7 +187,7 @@ def log_failures(failures: list[UiFailureTotal], title: str = "Failures:", last_return error_padding-def get_input(manager: Manager) -> str:+def get_input(manager: Manager) -> Text | str:if manager.parsed_args.cli_only_args.retry_all:return "--retry-all"if manager.parsed_args.cli_only_args.retry_failed:@@ -196,7 +199,27 @@ def get_input(manager: Manager) -> str:return "--links (CLI args)"-def get_console_hyperlink(file_path: Path, text: str = "") -> str:+def get_console_hyperlink(file_path: Path, text: str = "") -> Text:full_path = file_path.resolve()show_text = text or full_path- return f"[link=file://{full_path}]{show_text}[/link]"+ file_url = URL(full_path.as_posix()).with_scheme("file")+ return Text(str(show_text), style=f"link {file_url}")+++def concat_as_text(*text_or_str, style: str = "") -> Text:+ result = Text()+ for elem in text_or_str:+ if isinstance(elem, Text):+ text = elem+ if style and text.style != style:+ text.stylize(f"{style} {text.style}")+ else:+ text = Text(elem, style=style)++ result.append(text)+ return result+++def log_concat(*text_or_str, style: str = "", **kwargs) -> None:+ text = concat_as_text(*text_or_str, style=style)+ log_with_color(text, style, **kwargs)diff --git a/cyberdrop_dl/utils/logger.py b/cyberdrop_dl/utils/logger.pyindex 5322ac3a6..2b7811cbf 100644--- a/cyberdrop_dl/utils/logger.py+++ b/cyberdrop_dl/utils/logger.py@@ -144,13 +144,9 @@ def log_debug(message: Exception | str, level: int = 10, **kwargs) -> None:logger_debug.log(level, message.encode("ascii", "ignore").decode("ascii"), **kwargs)-def log_with_color(- message: str, style: str, level: int, show_in_stats: bool = True, markup: bool = False, **kwargs-) -> None:+def log_with_color(message: Text | str, style: str, level: int = 20, show_in_stats: bool = True, **kwargs) -> None:"""Simple logging function with color."""- text = Text(message, style=style)- if markup:- text = Text.from_markup(message, style=style)+ text = message if isinstance(message, Text) else Text(message, style=style)log(text.plain, level, **kwargs)if constants.CONSOLE_LEVEL >= 50:console.print(text)