Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: remove old code

NTFSvolumee720f07835ad
diff --git a/cyberdrop_dl/constants.py b/cyberdrop_dl/constants.py
index 9475c2a20..5de67803c 100644
--- a/cyberdrop_dl/constants.py
+++ b/cyberdrop_dl/constants.py
@@ -2,10 +2,9 @@ from __future__ import annotations
import datetime
from contextvars import ContextVar
-from enum import Enum, StrEnum, auto
+from enum import StrEnum, auto
from typing import TYPE_CHECKING, final
-from rich.text import Text
from typing_extensions import Sentinel
from cyberdrop_dl import __version__, env
@@ -63,12 +62,6 @@ class BlockedDomains:
exact_match = *exact_match, "x.com"
-class HashType(StrEnum):
- md5 = "md5"
- sha256 = "sha256"
- xxh128 = "xxh128"
-
-
class HashMode(CIStrEnum):
OFF = auto()
IN_PLACE = auto()
@@ -79,26 +72,6 @@ class HashMode(CIStrEnum):
return self is not HashMode.OFF
-class Browser(StrEnum):
- chrome = auto()
- firefox = auto()
- safari = auto()
- edge = auto()
- opera = auto()
- brave = auto()
- librewolf = auto()
- opera_gx = auto()
- vivaldi = auto()
- chromium = auto()
-
-
-class NotificationResult(Enum):
- SUCCESS = Text("Success", "green")
- FAILED = Text("Failed", "bold red")
- PARTIAL = Text("Partial Success", "yellow")
- NONE = Text("No Notifications Sent", "yellow")
-
-
@final
class FileExt:
IMAGE = frozenset(
diff --git a/cyberdrop_dl/cookies.py b/cyberdrop_dl/cookies.py
index 3c7e58811..568d2d70a 100644
--- a/cyberdrop_dl/cookies.py
+++ b/cyberdrop_dl/cookies.py
@@ -11,7 +11,7 @@ from typing import TYPE_CHECKING
from cyberdrop_dl import aio
if TYPE_CHECKING:
- from collections.abc import AsyncGenerator, Generator, Iterable, Sequence
+ from collections.abc import AsyncGenerator, Generator, Sequence
from pathlib import Path
@@ -26,44 +26,6 @@ if sys.version_info < (3, 14):
logger = logging.getLogger(__name__)
-def filter(cookies: Iterable[Cookie], domains: list[str] | None = None) -> Generator[Cookie]: # noqa: A001
- if not domains:
- yield from cookies
- else:
- allowed_domains = tuple(domains)
- for cookie in cookies:
- if cookie.domain.endswith(allowed_domains):
- yield cookie
-
-
-def split(extracted_cookies: Iterable[Cookie]) -> dict[str, MozillaCookieJar]:
- cookie_jars: dict[str, MozillaCookieJar] = {}
- for cookie in extracted_cookies:
- domain = cookie.domain.lstrip(".").removeprefix("www.")
- cookie_jar = cookie_jars.get(domain)
- if cookie_jar is None:
- cookie_jars[domain] = cookie_jar = MozillaCookieJar()
- cookie_jar.set_cookie(cookie)
-
- return cookie_jars
-
-
-async def export(cookies: Iterable[Cookie], output_path: Path) -> None:
- cookie_jars = split(cookies)
- await asyncio.to_thread(output_path.mkdir, parents=True, exist_ok=True)
- _ = await aio.gather(
- *(
- asyncio.to_thread(
- cj.save,
- str(output_path / f"{domain}.txt"),
- ignore_discard=True,
- ignore_expires=True,
- )
- for domain, cj in cookie_jars.items()
- )
- )
-
-
async def read_netscape_files(cookie_files: Sequence[Path]) -> AsyncGenerator[SimpleCookie]:
now = int(time.time())
all_domains: set[str] = set()
diff --git a/tests/test_cookies.py b/tests/test_cookies.py
index b5ad42764..55e3992b8 100644
--- a/tests/test_cookies.py
+++ b/tests/test_cookies.py
@@ -4,7 +4,7 @@ from http.cookiejar import Cookie, MozillaCookieJar
from http.cookies import SimpleCookie
from typing import TYPE_CHECKING
-from cyberdrop_dl.cookies import _parse_cookie_jar, make_simple_cookie, split
+from cyberdrop_dl.cookies import _parse_cookie_jar, make_simple_cookie
if TYPE_CHECKING:
import pytest
@@ -90,23 +90,6 @@ class TestMakeSimpleCookie:
assert simple["old"]["max-age"] == "0"
-def test_split_cookies() -> None:
- cookies = [
- make_cookie(name="session", value="abc123", domain="example.com"),
- make_cookie(name="user", value="user123", domain="www.example.com"),
- make_cookie(name="user", value="user123", domain="example2.com"),
- ]
- cookie_jar = MozillaCookieJar()
- for cookie in cookies:
- cookie_jar.set_cookie(cookie)
-
- output = split(cookie_jar)
- assert type(next(iter(output.values()))) is MozillaCookieJar
- assert tuple(output) == ("example.com", "example2.com")
- assert len(output["example.com"]) == 2
- assert len(output["example2.com"]) == 1
-
-
def test_parse_cookie_jar() -> None:
cookie_jar = MozillaCookieJar()
cookie = make_cookie(name="session", value="abc123", domain="www.example.com")
diff --git a/tests/test_files/apprise/empty_file.txt b/tests/test_files/apprise/empty_file.txt
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tests/test_files/apprise/invalid_multiple_urls.txt b/tests/test_files/apprise/invalid_multiple_urls.txt
deleted file mode 100644
index 3de4713b6..000000000
--- a/tests/test_files/apprise/invalid_multiple_urls.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-tgram://bottoken/ChatID
-not_an_url
-also_not_an_url
diff --git a/tests/test_files/apprise/invalid_single_url.txt b/tests/test_files/apprise/invalid_single_url.txt
deleted file mode 100644
index b593756c4..000000000
--- a/tests/test_files/apprise/invalid_single_url.txt
+++ /dev/null
@@ -1 +0,0 @@
-not_an_url
diff --git a/tests/test_files/apprise/valid_multiple_urls.txt b/tests/test_files/apprise/valid_multiple_urls.txt
deleted file mode 100644
index bc7add847..000000000
--- a/tests/test_files/apprise/valid_multiple_urls.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-discord://avatar@webhook_id/webhook_token
-windows://
-another_tag=enigma2://hostname
-attach_logs=reddit://user:password@app_id/app_secret/subreddit
-tag_1,tag2=mailto://domain.com?user=userid&pass=password
diff --git a/tests/test_files/apprise/valid_single_url.txt b/tests/test_files/apprise/valid_single_url.txt
deleted file mode 100644
index b73a31297..000000000
--- a/tests/test_files/apprise/valid_single_url.txt
+++ /dev/null
@@ -1 +0,0 @@
-tgram://bottoken/ChatID