Skip to content

Bulk asynchronous downloader for multiple file hosts

Improve Cookie Import (#754)

Jacobf6575b02eb3c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 035166f81..37fb5bede 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,10 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [UNRELEASED]
+### Added
+
+- Add an option to import cookies from all supported sites
+
### Changed
- Speed up checking for empty files & folders by up to 2x
- Speed up sorting files by up to 1.5x
+- Remove browsers that aren't supported by the user's OS from the list of available browsers
+
+### Fixed
+
+- Fixed an error when trying to select done after choosing to import cookies
## [6.6.1] - 2025-02-28
diff --git a/cyberdrop_dl/ui/prompts/user_prompts.py b/cyberdrop_dl/ui/prompts/user_prompts.py
index 4172ec332..48ccbf20a 100644
--- a/cyberdrop_dl/ui/prompts/user_prompts.py
+++ b/cyberdrop_dl/ui/prompts/user_prompts.py
@@ -2,6 +2,7 @@ from __future__ import annotations
import asyncio
from enum import IntEnum
+from platform import system
from typing import TYPE_CHECKING
from InquirerPy import get_style
@@ -17,7 +18,11 @@ from cyberdrop_dl.ui.prompts import basic_prompts
from cyberdrop_dl.ui.prompts.defaults import ALL_CHOICE, DONE_CHOICE, EXIT_CHOICE
from cyberdrop_dl.utils.constants import BROWSERS, RESERVED_CONFIG_NAMES
from cyberdrop_dl.utils.cookie_management import get_cookies_from_browsers
-from cyberdrop_dl.utils.data_enums_classes.supported_domains import SUPPORTED_FORUMS, SUPPORTED_WEBSITES
+from cyberdrop_dl.utils.data_enums_classes.supported_domains import (
+ SUPPORTED_FORUMS,
+ SUPPORTED_SITES_DOMAINS,
+ SUPPORTED_WEBSITES,
+)
from cyberdrop_dl.utils.utilities import clear_term
if TYPE_CHECKING:
@@ -154,12 +159,15 @@ class DomainType(IntEnum):
def domains_prompt(*, domain_message: str = "Select site(s):") -> tuple[list[str], list[str]]:
"""Asks the user to select website(s) for cookie actions and cache actions."""
- OPTIONS = [["forum", "file-host"]]
+ OPTIONS = [["Forum", "File Host"], ["All Supported Websites"]]
choices = basic_prompts.create_choices(OPTIONS)
domain_type = basic_prompts.ask_choice(choices, message="Select category:")
if domain_type == DONE_CHOICE.value:
- return []
+ return [], []
+
+ if domain_type == 3:
+ return SUPPORTED_SITES_DOMAINS, SUPPORTED_SITES_DOMAINS
all_domains = list(SUPPORTED_FORUMS.values() if domain_type == DomainType.FORUM else SUPPORTED_WEBSITES.values())
domain_choices = [Choice(site) for site in all_domains] + [ALL_CHOICE]
@@ -193,6 +201,8 @@ def extract_cookies(manager: Manager, *, dry_run: bool = False) -> None:
"""Asks the user to select browser(s) and domains(s) to import cookies from."""
domains, all_domains = domains_prompt(domain_message="Select site(s) to import cookies from:")
+ if domains == []:
+ return
browsers = browser_prompt()
if ALL_CHOICE.value in browsers:
@@ -211,7 +221,13 @@ def extract_cookies(manager: Manager, *, dry_run: bool = False) -> None:
def browser_prompt() -> str:
- choices = [Choice(browser, browser.capitalize()) for browser in BROWSERS]
+ """Asks the user to select browser(s) for cookie extraction."""
+ unsupported_browsers = {
+ "Windows": {"safari"},
+ "Linux": {"safari", "edge"},
+ "Darwin": {"edge"},
+ }.get(system(), set())
+ choices = [Choice(browser, browser.capitalize()) for browser in BROWSERS if browser not in unsupported_browsers]
return basic_prompts.ask_checkbox(choices, message="Select the browser(s) for extraction:")