Skip to content

Bulk asynchronous downloader for multiple file hosts

perf: only compute domain removal if required (#1266)

NTFSvolumebe1d472d4808
diff --git a/cyberdrop_dl/data_structures/url_objects.py b/cyberdrop_dl/data_structures/url_objects.py
index 5db2e02bc..c8c8f0657 100644
--- a/cyberdrop_dl/data_structures/url_objects.py
+++ b/cyberdrop_dl/data_structures/url_objects.py
@@ -256,18 +256,18 @@ class ScrapeItem:
if not title or self.retry:
return
title = sanitize_folder(title)
-
- for part in reversed(self.parent_title.split("/")):
- if part.endswith(")") and " (" in part:
- last_domain_suffix = part.rpartition(" (")[-1]
- break
- else:
- last_domain_suffix = None
-
- if last_domain_suffix and title.endswith(")") and " (" in title:
- og_title, _, domain_suffix = title.rpartition(" (")
- if last_domain_suffix == domain_suffix:
- title = og_title
+ if title.endswith(")") and " (" in title:
+ for part in reversed(self.parent_title.split("/")):
+ if part.endswith(")") and " (" in part:
+ last_domain_suffix = part.rpartition(" (")[-1]
+ break
+ else:
+ last_domain_suffix = None
+
+ if last_domain_suffix:
+ og_title, _, domain_suffix = title.rpartition(" (")
+ if last_domain_suffix == domain_suffix:
+ title = og_title
self.parent_title = (self.parent_title + "/" + title) if self.parent_title else title