Skip to content

Bulk asynchronous downloader for multiple file hosts

Fix bunkr.la, and output files new line during creation, added another failed url print for 400-500 code.

Jules-WinnfieldXd6a0a2d98809
diff --git a/cyberdrop_dl/crawlers/Bunkr_Spider.py b/cyberdrop_dl/crawlers/Bunkr_Spider.py
index 78b0d5667..e3aa18c0d 100644
--- a/cyberdrop_dl/crawlers/Bunkr_Spider.py
+++ b/cyberdrop_dl/crawlers/Bunkr_Spider.py
@@ -46,6 +46,7 @@ class BunkrCrawler:
if ext in FILE_FORMATS['Images']:
check_complete = await self.SQL_Helper.check_complete_singular("bunkr", url.path)
url = URL(str(url).replace("https://cdn", "https://i"))
+ url = await self.check_for_la(url)
filename, ext = await get_filename_and_ext(url.name)
if self.remove_bunkr_id:
@@ -73,6 +74,12 @@ class BunkrCrawler:
filename = filename + ext
return filename
+ async def check_for_la(self, url: URL):
+ if "12" in url.host:
+ url_host = url.host.replace(".su", ".la").replace(".ru", ".la")
+ url = url.with_host(url_host)
+ return url
+
async def get_file(self, session: ScrapeSession, url: URL):
"""Gets the media item from the supplied url"""
try:
@@ -89,6 +96,7 @@ class BunkrCrawler:
if not link:
raise
link = URL(link)
+ link = await self.check_for_la(link)
filename, ext = await get_filename_and_ext(link.name)
if self.remove_bunkr_id:
filename = await self.remove_id(filename, ext)
@@ -136,6 +144,8 @@ class BunkrCrawler:
else:
link = URL(f"https://media-files{media_loc}.bunkr.ru" + link.path)
+ link = await self.check_for_la(link)
+
if self.remove_bunkr_id:
filename = await self.remove_id(filename, ext)
diff --git a/cyberdrop_dl/downloader/downloaders.py b/cyberdrop_dl/downloader/downloaders.py
index 1c65d93fe..47e9edbc1 100644
--- a/cyberdrop_dl/downloader/downloaders.py
+++ b/cyberdrop_dl/downloader/downloaders.py
@@ -313,6 +313,8 @@ class Downloader:
self.files.failed_files += 1
if media.url.parts[-1] in self.current_attempt.keys():
self.current_attempt.pop(media.url.parts[-1])
+ async with aiofiles.open(self.output_errored_file, mode='a') as file:
+ await file.write(f"{media.url},{media.referer},{e.message}\n")
return
logger.debug("Error status code: " + str(e.code))
new_error.code = e.code
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.py
index 2fdbc85d4..9a35637c0 100644
--- a/cyberdrop_dl/main.py
+++ b/cyberdrop_dl/main.py
@@ -14,7 +14,7 @@ from cyberdrop_dl.client.client import Client
from cyberdrop_dl.downloader.downloaders import download_cascade, download_forums
from cyberdrop_dl.scraper.Scraper import ScrapeMapper
from . import __version__ as VERSION
-from .base_functions.data_classes import SkipData, CascadeItem, ForumItem
+from .base_functions.data_classes import SkipData, CascadeItem
def parse_args() -> argparse.Namespace:
@@ -114,7 +114,7 @@ async def file_management(args: dict, links: list) -> None:
unsupported_urls.unlink()
unsupported_urls.touch()
async with aiofiles.open(unsupported_urls, mode='w') as f:
- await f.write("URL,REFERER,TITLE")
+ await f.write("URL,REFERER,TITLE\n")
if args['Runtime']['output_errored_urls']:
errored_urls = args['Files']['errored_urls_file']
@@ -122,7 +122,7 @@ async def file_management(args: dict, links: list) -> None:
errored_urls.unlink()
errored_urls.touch()
async with aiofiles.open(errored_urls, mode='w') as f:
- await f.write("URL,REFERER,REASON")
+ await f.write("URL,REFERER,REASON\n")
async def consolidate_links(args: dict, links: list) -> list:
diff --git a/cyberdrop_dl/scraper/Scraper.py b/cyberdrop_dl/scraper/Scraper.py
index f5d8bbe7f..48c66b8c3 100644
--- a/cyberdrop_dl/scraper/Scraper.py
+++ b/cyberdrop_dl/scraper/Scraper.py
@@ -288,6 +288,7 @@ class ScrapeMapper:
await coomeno_session.exit_handler()
return
if title:
+ await cascade.append_title(title)
await self.Forums.extend_thread(title, cascade)
else:
await self.Forums.add_thread(new_title, cascade)