Skip to content

Bulk asynchronous downloader for multiple file hosts

feat: allow selective sorting

NTFSvolumef961f6605f3e
diff --git a/cyberdrop_dl/config_definitions/config_settings.py b/cyberdrop_dl/config_definitions/config_settings.py
index c5fb01c23..d6a431807 100644
--- a/cyberdrop_dl/config_definitions/config_settings.py
+++ b/cyberdrop_dl/config_definitions/config_settings.py
@@ -134,12 +134,12 @@ class Sorting(BaseModel):
scan_folder: Path | None = None
sort_cdl_only: bool = True
sort_incremementer_format: NonEmptyStr = " ({i})"
- sorted_audio: NonEmptyStr = "{sort_dir}/{base_dir}/Audio/{filename}{ext}"
- sorted_image: NonEmptyStr = "{sort_dir}/{base_dir}/Images/{filename}{ext}"
- sorted_other: NonEmptyStr = "{sort_dir}/{base_dir}/Other/{filename}{ext}"
- sorted_video: NonEmptyStr = "{sort_dir}/{base_dir}/Videos/{filename}{ext}"
+ sorted_audio: NonEmptyStr | None = "{sort_dir}/{base_dir}/Audio/{filename}{ext}"
+ sorted_image: NonEmptyStr | None = "{sort_dir}/{base_dir}/Images/{filename}{ext}"
+ sorted_other: NonEmptyStr | None = "{sort_dir}/{base_dir}/Other/{filename}{ext}"
+ sorted_video: NonEmptyStr | None = "{sort_dir}/{base_dir}/Videos/{filename}{ext}"
- @field_validator("scan_folder", mode="before")
+ @field_validator("scan_folder", "sorted_audio", "sorted_image", "sorted_other", "sorted_video", mode="before")
@classmethod
def handle_falsy(cls, value: str) -> str | None:
if not value or value == "None":
diff --git a/cyberdrop_dl/utils/sorting.py b/cyberdrop_dl/utils/sorting.py
index ef427a365..9463d1694 100644
--- a/cyberdrop_dl/utils/sorting.py
+++ b/cyberdrop_dl/utils/sorting.py
@@ -148,6 +148,8 @@ class Sorter:
def sort_audio(self, file: Path, base_name: str) -> None:
"""Sorts an audio file into the sorted audio folder."""
+ if not self.audio_format:
+ return
self.audio_count += 1
length = bitrate = sample_rate = "Unknown"
with contextlib.suppress(RuntimeError, subprocess.CalledProcessError):
@@ -161,6 +163,8 @@ class Sorter:
def sort_image(self, file: Path, base_name: str) -> None:
"""Sorts an image file into the sorted image folder."""
+ if not self.image_format:
+ return
self.image_count += 1
resolution = "Unknown"
with contextlib.suppress(PIL.UnidentifiedImageError, PIL.Image.DecompressionBombError): # type: ignore
@@ -174,6 +178,8 @@ class Sorter:
def sort_video(self, file: Path, base_name: str) -> None:
"""Sorts a video file into the sorted video folder."""
+ if not self.video_format:
+ return
self.video_count += 1
resolution = frames_per_sec = codec = "Unknown"
@@ -191,6 +197,8 @@ class Sorter:
def sort_other(self, file: Path, base_name: str) -> None:
"""Sorts an other file into the sorted other folder."""
+ if not self.other_format:
+ return
self.other_count += 1
if self._process_file_move(file, base_name):
self.manager.progress_manager.sort_progress.increment_other()