diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.py index 116f3bba1..6a9f79b3c 100644 --- a/cyberdrop_dl/main.py +++ b/cyberdrop_dl/main.py @@ -10,6 +10,7 @@ from time import perf_counter from typing import TYPE_CHECKING +import browser_cookie3 from pydantic import ValidationError from rich.console import Console from rich.logging import RichHandler @@ -66,6 +67,10 @@ def startup() -> Manager | None: startup_logger.info("Exiting...") sys.exit(0) + except browser_cookie3.BrowserCookieError: + startup_logger.exception("") + sys.exit(1) + except Exception: msg = "An error occurred, please report this to the developer with your logs file:" startup_logger.exception(msg) @@ -199,8 +204,9 @@ async def wrapper(*args, **kwargs): exceptions = [e] if isinstance(e, ExceptionGroup): exceptions = e.exceptions - msg = "An error occurred, please report this to the developer with your logs file:" - log_with_color(msg, "bold red", 50, show_in_stats=False) + if not isinstance(exceptions[0], browser_cookie3.BrowserCookieError): + msg = "An error occurred, please report this to the developer with your logs file:" + log_with_color(msg, "bold red", 50, show_in_stats=False) for exc in exceptions: log_with_color(f" {exc}", "bold red", 50, show_in_stats=False, exc_info=exc) diff --git a/cyberdrop_dl/utils/cookie_management.py b/cyberdrop_dl/utils/cookie_management.py index d7eab6f79..be996ad16 100644 --- a/cyberdrop_dl/utils/cookie_management.py +++ b/cyberdrop_dl/utils/cookie_management.py @@ -35,23 +35,19 @@ def wrapper(*args, **kwargs) -> None: try: return func(*args, **kwargs) except PermissionError: - msg = """ - We've encountered a Permissions Error. Please close all browsers and try again - If you are still having issues, make sure all browsers processes are closed in Task Manager - """ + msg = """We've encountered a Permissions Error. Please close all browsers and try again + If you are still having issues, make sure all browsers processes are closed in Task Manager""" msg = dedent(msg) except ValueError as e: msg = str(e) except UnsupportedBrowserError as e: - msg = f"\nERROR: {e!s}" + msg = f"ERROR: {e!s}" except browser_cookie3.BrowserCookieError as e: - msg = """ - Browser extraction ran into an error, the selected browser(s) may not be available on your system - If you are still having issues, make sure all browsers processes are closed in Task Manager. - """ + msg = """Browser extraction ran into an error, the selected browser(s) may not be available on your system + If you are still having issues, make sure all browsers processes are closed in Task Manager.""" msg = dedent(msg) + f"\nERROR: {e!s}" @@ -72,6 +68,7 @@ def get_cookies_from_browsers( raise ValueError(msg) browsers = browsers or manager.config_manager.settings_data.browser_cookies.browsers + browsers = list(map(str.lower, browsers)) domains: list[str] = domains or manager.config_manager.settings_data.browser_cookies.sites extractors = [(str(b), getattr(browser_cookie3, b)) for b in browsers if hasattr(browser_cookie3, b)]