Skip to content

Bulk asynchronous downloader for multiple file hosts

add missing from conf, add different semaphores for domain limits

Jules-WinnfieldX006c875d6f4d
diff --git a/cyberdrop_dl/base_functions/config_schema.py b/cyberdrop_dl/base_functions/config_schema.py
index 184e88105..90c138968 100644
--- a/cyberdrop_dl/base_functions/config_schema.py
+++ b/cyberdrop_dl/base_functions/config_schema.py
@@ -89,6 +89,6 @@ ratelimiting_args = ["connection_timeout", "ratelimit", "throttle"]
runtime_args = ["simultaneous_downloads", "allow_insecure_connections", "attempts", "disable_attempt_limit",
"include_id", "mark_downloaded", "proxy", "required_free_space", "output_errored_urls",
- "output_unsupported_urls"]
+ "output_unsupported_urls", "block_sub_folders"]
sorting_args = ["sort_downloads", "sort_directory", "sorted_audio", "sorted_images", "sorted_others", "sorted_videos"]
diff --git a/cyberdrop_dl/downloader/downloaders.py b/cyberdrop_dl/downloader/downloaders.py
index ea0d5db22..55af9ba28 100644
--- a/cyberdrop_dl/downloader/downloaders.py
+++ b/cyberdrop_dl/downloader/downloaders.py
@@ -63,8 +63,8 @@ class Files:
class Downloader:
"""Downloader class, directs downloading for domain objects"""
def __init__(self, args: dict, client: Client, SQL_Helper: SQLHelper, scraper: ScrapeMapper, max_workers: int,
- domain: str, domain_obj: DomainItem, semaphore: asyncio.Semaphore, dual_semaphore: asyncio.Semaphore,
- files: Files):
+ domain: str, domain_obj: DomainItem, semaphore: asyncio.Semaphore, bunkr_semaphore: asyncio.Semaphore,
+ pixeldrain_semaphore: asyncio.Semaphore, anonfiles_semaphore: asyncio.Semaphore, files: Files):
self.backup_scraper = scraper
self.client = client
self.download_session = DownloadSession(client, args["Ratelimiting"]["connection_timeout"])
@@ -82,7 +82,9 @@ class Downloader:
self.current_attempt = {}
self.max_workers = max_workers
self._semaphore = semaphore
- self._restricted_semaphore = dual_semaphore
+ self._bunkr_semaphore = bunkr_semaphore
+ self._pixeldrain_semaphore = pixeldrain_semaphore
+ self._anonfiles_semaphore = anonfiles_semaphore
self.delay = {'cyberfile': 1, 'anonfiles': 1, "coomer": 0.2, "kemono": 0.2}
self.pixeldrain_api_key = args["Authentication"]["pixeldrain_api_key"]
@@ -139,8 +141,14 @@ class Downloader:
album_progress.advance(album_task, 1)
return
- if 'bunkr' in self.domain or 'pixeldrain' in self.domain or 'anonfiles' in self.domain:
- async with self._restricted_semaphore:
+ if 'bunkr' in self.domain:
+ async with self._bunkr_semaphore:
+ await self.download_file(album_task, album, media)
+ elif 'pixeldrain' in self.domain:
+ async with self._pixeldrain_semaphore:
+ await self.download_file(album_task, album, media)
+ elif 'anonfiles' in self.domain:
+ async with self._anonfiles_semaphore:
await self.download_file(album_task, album, media)
else:
async with self._semaphore:
@@ -362,11 +370,14 @@ async def download_forums(args: dict, Forums: ForumItem, SQL_Helper: SQLHelper,
tasks = []
threads = user_threads if user_threads != 0 else multiprocessing.cpu_count()
download_semaphore = asyncio.Semaphore(threads)
- dual_semaphore = asyncio.Semaphore(2 if threads > 2 else threads)
+ bunkr_semaphore = asyncio.Semaphore(2 if threads > 2 else threads)
+ pixeldrain_semaphore = asyncio.Semaphore(2 if threads > 2 else threads)
+ anonfiles_semaphore = asyncio.Semaphore(2 if threads > 2 else threads)
for domain, domain_obj in Cascade.domains.items():
downloaders.append(Downloader(args, client, SQL_Helper, scraper, threads, domain, domain_obj,
- download_semaphore, dual_semaphore, files))
+ download_semaphore, bunkr_semaphore, pixeldrain_semaphore,
+ anonfiles_semaphore, files))
for downloader in downloaders:
tasks.append(downloader.start_domain(cascade_task))
await asyncio.gather(*tasks)