Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: move filepath utils to root

NTFSvolume97e2b7b9ed5b
diff --git a/cyberdrop_dl/crawlers/crawler.py b/cyberdrop_dl/crawlers/crawler.py
index eebee56e0..35990a755 100644
--- a/cyberdrop_dl/crawlers/crawler.py
+++ b/cyberdrop_dl/crawlers/crawler.py
@@ -22,6 +22,12 @@ from cyberdrop_dl.constants import CDL_USER_AGENT
from cyberdrop_dl.crawlers._hls import HLSMixin
from cyberdrop_dl.downloader.http import Downloader
from cyberdrop_dl.exceptions import MaxChildrenError, NoExtensionError, ScrapeError
+from cyberdrop_dl.filepath import (
+ check_dangerous_filename,
+ check_path_traversal,
+ compose_filename,
+ get_filename_and_ext,
+)
from cyberdrop_dl.mediaprops import ISO639Subtitle, Resolution
from cyberdrop_dl.url_objects import AbsoluteHttpURL, MediaItem, ScrapeItem
from cyberdrop_dl.utils import (
@@ -34,12 +40,6 @@ from cyberdrop_dl.utils import (
parse_url,
unique,
)
-from cyberdrop_dl.utils.filepath import (
- check_dangerous_filename,
- check_path_traversal,
- compose_filename,
- get_filename_and_ext,
-)
from cyberdrop_dl.utils.strings import safe_format
if TYPE_CHECKING:
diff --git a/cyberdrop_dl/crawlers/cyberdrop.py b/cyberdrop_dl/crawlers/cyberdrop.py
index b52e32837..33ce46000 100644
--- a/cyberdrop_dl/crawlers/cyberdrop.py
+++ b/cyberdrop_dl/crawlers/cyberdrop.py
@@ -4,9 +4,9 @@ from typing import TYPE_CHECKING, ClassVar
from cyberdrop_dl import aio
from cyberdrop_dl.crawlers.crawler import API, Crawler, RateLimit, SupportedDomains, SupportedPaths
+from cyberdrop_dl.filepath import remove_file_id
from cyberdrop_dl.url_objects import AbsoluteHttpURL
from cyberdrop_dl.utils import css, error_handling_wrapper
-from cyberdrop_dl.utils.filepath import remove_file_id
if TYPE_CHECKING:
from cyberdrop_dl.url_objects import ScrapeItem
diff --git a/cyberdrop_dl/crawlers/hitomi_la.py b/cyberdrop_dl/crawlers/hitomi_la.py
index 831ceb252..2eb467ea0 100644
--- a/cyberdrop_dl/crawlers/hitomi_la.py
+++ b/cyberdrop_dl/crawlers/hitomi_la.py
@@ -13,9 +13,9 @@ from typing import TYPE_CHECKING, Any, ClassVar
from cyberdrop_dl import aio
from cyberdrop_dl.crawlers.crawler import API, Crawler, SupportedPaths
from cyberdrop_dl.exceptions import ScrapeError
+from cyberdrop_dl.filepath import get_filename_and_ext
from cyberdrop_dl.url_objects import AbsoluteHttpURL
from cyberdrop_dl.utils import DictDataclass, error_handling_wrapper
-from cyberdrop_dl.utils.filepath import get_filename_and_ext
if TYPE_CHECKING:
from collections.abc import AsyncGenerator, Generator, Iterable, Mapping
diff --git a/cyberdrop_dl/crawlers/http_direct.py b/cyberdrop_dl/crawlers/http_direct.py
index b2190a8f6..51815a3fc 100644
--- a/cyberdrop_dl/crawlers/http_direct.py
+++ b/cyberdrop_dl/crawlers/http_direct.py
@@ -6,7 +6,7 @@ from cyberdrop_dl.constants import FileExt
from cyberdrop_dl.crawlers.crawler import Crawler
from cyberdrop_dl.downloader.http import Downloader
from cyberdrop_dl.exceptions import NoExtensionError
-from cyberdrop_dl.utils.filepath import get_filename_and_ext
+from cyberdrop_dl.filepath import get_filename_and_ext
if TYPE_CHECKING:
from cyberdrop_dl.url_objects import ScrapeItem
diff --git a/cyberdrop_dl/csv_logs.py b/cyberdrop_dl/csv_logs.py
index efb792a8a..703aefa26 100644
--- a/cyberdrop_dl/csv_logs.py
+++ b/cyberdrop_dl/csv_logs.py
@@ -10,8 +10,8 @@ from typing import TYPE_CHECKING, Any, Self
from cyberdrop_dl import constants
from cyberdrop_dl.exceptions import get_origin
+from cyberdrop_dl.filepath import sanitize_filename
from cyberdrop_dl.utils import json
-from cyberdrop_dl.utils.filepath import sanitize_filename
if TYPE_CHECKING:
import datetime
diff --git a/cyberdrop_dl/database/transfer.py b/cyberdrop_dl/database/transfer.py
index 101c0d0b5..5222fca26 100644
--- a/cyberdrop_dl/database/transfer.py
+++ b/cyberdrop_dl/database/transfer.py
@@ -11,9 +11,9 @@ from cyberdrop_dl import database
from cyberdrop_dl.database import common
from cyberdrop_dl.database.history import apply_fixes
from cyberdrop_dl.database.schema import CURRENT_VERSION, Version
+from cyberdrop_dl.filepath import sanitize_filename
from cyberdrop_dl.logs import setup_console_logging
from cyberdrop_dl.utils import dates
-from cyberdrop_dl.utils.filepath import sanitize_filename
logger = logging.getLogger(__name__)
diff --git a/cyberdrop_dl/utils/filepath.py b/cyberdrop_dl/filepath.py
similarity index 100%
rename from cyberdrop_dl/utils/filepath.py
rename to cyberdrop_dl/filepath.py
diff --git a/cyberdrop_dl/scrape_mapper.py b/cyberdrop_dl/scrape_mapper.py
index 0d95a92a8..3f845fc39 100644
--- a/cyberdrop_dl/scrape_mapper.py
+++ b/cyberdrop_dl/scrape_mapper.py
@@ -10,7 +10,7 @@ from typing import TYPE_CHECKING, Any, Literal, Self
from pydantic.types import ByteSize
-from cyberdrop_dl import aio, plugins, storage
+from cyberdrop_dl import aio, filepath, plugins, storage
from cyberdrop_dl.clients.jdownloader import JDownloader
from cyberdrop_dl.constants import BlockedDomains
from cyberdrop_dl.crawlers import create_crawlers
@@ -25,7 +25,7 @@ from cyberdrop_dl.exceptions import JDownloaderError, NoExtensionError
from cyberdrop_dl.logs import log_spacer
from cyberdrop_dl.progress.scraping import ScrapingUI
from cyberdrop_dl.url_objects import AbsoluteHttpURL, ScrapeItem
-from cyberdrop_dl.utils import filepath, remove_trailing_slash
+from cyberdrop_dl.utils import remove_trailing_slash
if TYPE_CHECKING:
from collections.abc import AsyncGenerator, Coroutine, Generator, Iterable, Iterator, Sequence
diff --git a/cyberdrop_dl/url_objects.py b/cyberdrop_dl/url_objects.py
index 42a3fc00a..c1d984547 100644
--- a/cyberdrop_dl/url_objects.py
+++ b/cyberdrop_dl/url_objects.py
@@ -13,7 +13,7 @@ from typing import TYPE_CHECKING, Any, Literal, NamedTuple, Self, final, overloa
import yarl
from cyberdrop_dl.exceptions import MaxChildrenError
-from cyberdrop_dl.utils.filepath import sanitize_folder
+from cyberdrop_dl.filepath import sanitize_folder
if TYPE_CHECKING:
from collections.abc import Generator, Iterable, Sequence
diff --git a/tests/test_filename_safeguards.py b/tests/test_filename_safeguards.py
index ac9f5345f..a5fff78d7 100644
--- a/tests/test_filename_safeguards.py
+++ b/tests/test_filename_safeguards.py
@@ -3,7 +3,7 @@ from pathlib import Path
import pytest
from cyberdrop_dl.exceptions import FileNameError, PathTraversalError
-from cyberdrop_dl.utils.filepath import check_dangerous_filename, check_path_traversal
+from cyberdrop_dl.filepath import check_dangerous_filename, check_path_traversal
def test_path_inside_dl_folder_are_ok(tmp_path: Path) -> None:
diff --git a/tests/test_unicode_emoji_sanitization.py b/tests/test_unicode_emoji_sanitization.py
index f72350ad3..ecdc89e99 100644
--- a/tests/test_unicode_emoji_sanitization.py
+++ b/tests/test_unicode_emoji_sanitization.py
@@ -3,7 +3,7 @@ from pathlib import Path
import pytest
-from cyberdrop_dl.utils.filepath import remove_emojis_and_symbols, sanitize_filename
+from cyberdrop_dl.filepath import remove_emojis_and_symbols, sanitize_filename
IS_MACOS = sys.platform == "darwin"
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 5cfa365df..f6cb43f4e 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -7,7 +7,7 @@ from typing import Any
import pytest
from cyberdrop_dl.exceptions import InvalidExtensionError, NoExtensionError
-from cyberdrop_dl.utils.filepath import get_filename_and_ext
+from cyberdrop_dl.filepath import get_filename_and_ext
class TestGetFilenameAndExt: