Skip to content

Bulk asynchronous downloader for multiple file hosts

add config options and add partial use of new options

datawhoresa973485b2d8e
diff --git a/cyberdrop_dl/clients/hash_client.py b/cyberdrop_dl/clients/hash_client.py
index 289725465..b02a5629a 100644
--- a/cyberdrop_dl/clients/hash_client.py
+++ b/cyberdrop_dl/clients/hash_client.py
@@ -33,6 +33,8 @@ class HashClient:
return hash
async def cleanup_dupes(self):
+ if not self.manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['delete_after_download']:
+ return
hashes_dict=defaultdict(list)
# first compare downloads to each other
for item in self.manager.path_manager.completed_downloads:
@@ -58,12 +60,12 @@ class HashClient:
all_matches=list(map(lambda x:pathlib.Path(x[0],x[1]),await self.manager.db_manager.hash_table.get_files_with_hash_matches(hash)))
# delete files if more then one match exists
matches=list(filter(lambda x:x!=path and x.exists(),all_matches))
- if len(matches)>0:
+ if len(matches)==0:
+ continue
+ elif self.manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['keep_current_download']:
+ for ele in matches:
+ ele.unlink(missing_ok=True)
+ else:
path.unlink(missing_ok=True)
-
-
-
- #compare other files in folder, and remove downloaded if already exists
-
diff --git a/cyberdrop_dl/managers/config_manager.py b/cyberdrop_dl/managers/config_manager.py
index 5fe6ff82e..54eb97877 100644
--- a/cyberdrop_dl/managers/config_manager.py
+++ b/cyberdrop_dl/managers/config_manager.py
@@ -166,6 +166,14 @@ class ConfigManager:
self.global_settings_data['Rate_Limiting_Options']['read_timeout'] = int(
self.global_settings_data['Rate_Limiting_Options']['read_timeout'])
+ self.global_settings_data['Dupe_Cleanup_Options']['delete_after_download'] = \
+ self.global_settings_data['Dupe_Cleanup_Options']['delete_after_download']
+ self.global_settings_data['Dupe_Cleanup_Options']['hash_while_downloading'] = \
+ self.global_settings_data['Dupe_Cleanup_Options']['hash_while_downloading']
+ self.global_settings_data['Dupe_Cleanup_Options']['keep_current_download'] = \
+ self.global_settings_data['Dupe_Cleanup_Options']['keep_current_download']
+
+
self.global_settings_data['UI_Options']['refresh_rate'] = int(
self.global_settings_data['UI_Options']['refresh_rate'])
self.global_settings_data['UI_Options']['scraping_item_limit'] = int(
diff --git a/cyberdrop_dl/utils/args/config_definitions.py b/cyberdrop_dl/utils/args/config_definitions.py
index 3a390f117..407577162 100644
--- a/cyberdrop_dl/utils/args/config_definitions.py
+++ b/cyberdrop_dl/utils/args/config_definitions.py
@@ -133,6 +133,13 @@ global_settings: Dict = {
"max_simultaneous_downloads_per_domain": 5,
"download_speed_limit":0
},
+ "Dupe_Cleanup_Options":
+ {
+ "delete_after_download": False,
+ "hash_while_downloading": False,
+ "keep_current_download": False
+ },
+
"UI_Options": {
"vi_mode": False,
"refresh_rate": 10,