Skip to content

Bulk asynchronous downloader for multiple file hosts

Finish unsupported and errored files.

Jules-WinnfieldX426c632aa643
diff --git a/cyberdrop_dl/base_functions/config_schema.py b/cyberdrop_dl/base_functions/config_schema.py
index 7d55474cb..2187df356 100644
--- a/cyberdrop_dl/base_functions/config_schema.py
+++ b/cyberdrop_dl/base_functions/config_schema.py
@@ -4,6 +4,7 @@ config_default = [
"Apply_Config": False,
"Files": {
"db_file": "download_history.sqlite",
+ "errored_urls_file": "Errored_URLs.csv",
"input_file": "URLs.txt",
"log_file": "downloader.log",
"output_folder": "Downloads",
@@ -51,6 +52,8 @@ config_default = [
"disable_attempt_limit": False,
"include_id": False,
"mark_downloaded": False,
+ "output_errored_urls": False,
+ "output_unsupported_urls": False,
"proxy": "",
}
}
@@ -62,7 +65,8 @@ authentication_args = ["pixeldrain_api_key",
"socialmediagirls_username", "socialmediagirls_password",
"xbunker_username", "xbunker_password"]
-files_args = ["db_file", "input_file", "log_file", "output_folder", "output_last_forum_post_file", "unsupported_urls_file"]
+files_args = ["db_file", "input_file", "log_file", "output_folder", "output_last_forum_post_file",
+ "unsupported_urls_file", "errored_urls_file"]
forum_args = ["output_last_forum_post", "separate_posts"]
@@ -74,4 +78,5 @@ jdownloader_args = ["apply_jdownloader", "jdownloader_username", "jdownloader_pa
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"]
+ "include_id", "mark_downloaded", "proxy", "required_free_space", "output_errored_urls",
+ "output_unsupported_urls"]
diff --git a/cyberdrop_dl/downloader/downloaders.py b/cyberdrop_dl/downloader/downloaders.py
index 8e77b91fb..39e50378d 100644
--- a/cyberdrop_dl/downloader/downloaders.py
+++ b/cyberdrop_dl/downloader/downloaders.py
@@ -7,6 +7,7 @@ from base64 import b64encode
from functools import wraps
from random import gauss
+import aiofiles
import aiohttp.client_exceptions
from rich.progress import TaskID
from yarl import URL
@@ -34,6 +35,9 @@ def retry(f):
except DownloadFailure as e:
if not self.disable_attempt_limit:
if self.current_attempt[args[3].url.parts[-1]] >= self.allowed_attempts - 1:
+ if self.output_errored:
+ async with aiofiles.open(self.output_errored_file, mode='a') as file:
+ await file.write(f"{args[3].url},{args[3].referer},{e.message}")
logger.debug('Skipping %s...', args[3].url, exc_info=True)
self.files.failed_files += 1
break
@@ -64,6 +68,9 @@ class Downloader:
self.domain = domain
self.domain_obj = domain_obj
+ self.output_errored = args['Runtime']['output_unsupported_urls']
+ self.output_errored_file = args['Files']['errored_urls_file']
+
self.files = files
self.current_attempt = {}
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.py
index 40e80cd40..1b6f30150 100644
--- a/cyberdrop_dl/main.py
+++ b/cyberdrop_dl/main.py
@@ -92,12 +92,21 @@ async def file_management(args: dict, links: list) -> None:
output_url_file.unlink()
output_url_file.touch()
- unsupported_urls = args['Forum_Options']['unsupported_urls_file']
- if unsupported_urls.exists():
- unsupported_urls.unlink()
- unsupported_urls.touch()
- async with aiofiles.open(unsupported_urls, mode='w') as f:
- await f.write("URL,REFERER,TITLE")
+ if args['Runtime']['output_unsupported_urls']:
+ unsupported_urls = args['Forum_Options']['unsupported_urls_file']
+ if unsupported_urls.exists():
+ unsupported_urls.unlink()
+ unsupported_urls.touch()
+ async with aiofiles.open(unsupported_urls, mode='w') as f:
+ await f.write("URL,REFERER,TITLE")
+
+ if args['Runtime']['output_errored_urls']:
+ errored_urls = args['Forum_Options']['errored_urls_file']
+ if errored_urls.exists():
+ errored_urls.unlink()
+ errored_urls.touch()
+ async with aiofiles.open(errored_urls, mode='w') as f:
+ await f.write("URL,REFERER,REASON")
async def consolidate_links(args: dict, links: list) -> list:
diff --git a/cyberdrop_dl/scraper/Scraper.py b/cyberdrop_dl/scraper/Scraper.py
index 9a177f879..726f4f6ed 100644
--- a/cyberdrop_dl/scraper/Scraper.py
+++ b/cyberdrop_dl/scraper/Scraper.py
@@ -281,5 +281,6 @@ class ScrapeMapper:
else:
await log(f"[yellow]Not Supported: {str(url_to_map)}[/yellow]", quiet=self.quiet)
- async with aiofiles.open(self.args["Files"]["unsupported_urls_file"], mode='a') as f:
- await f.write(f"{str(url_to_map)},{str(referer)},{title}")
+ if self.args['Runtime']['output_unsupported_urls']:
+ async with aiofiles.open(self.args["Files"]["unsupported_urls_file"], mode='a') as f:
+ await f.write(f"{str(url_to_map)},{str(referer)},{title}")