Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Make all async
Jules-WinnfieldX686b8324863f
diff --git a/CHANGELOG.txt b/CHANGELOG.txtindex dc18e0990..5643bba52 100644--- a/CHANGELOG.txt+++ b/CHANGELOG.txt@@ -5,4 +5,8 @@ Made my custom log function also output to the Downloader.log file2.14.7Added handling for .mkv files because apparently that wasn't a thing I was doing.Add handling for more direct links from cyberdrop (maybe, might cause issues)-Fixed my instant returns for 400-500 status.\ No newline at end of file+Fixed my instant returns for 400-500 status.++2.14.9+We're trying just cyberdrop.to for faster cyberdrop downloads+Change all funcs to be async\ No newline at end of filediff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.pyindex 0f4330233..ef290d1ad 100644--- a/cyberdrop_dl/__init__.py+++ b/cyberdrop_dl/__init__.py@@ -1 +1 @@-__version__ = "2.14.8"+__version__ = "2.14.9"diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.pyindex 9520ce6c8..5131249f4 100644--- a/cyberdrop_dl/main.py+++ b/cyberdrop_dl/main.py@@ -33,28 +33,27 @@ def parse_args():async def download_all(args: argparse.Namespace):- clear()- log(f"We are running version {VERSION} of Cyberdrop Downloader", Fore.WHITE)+ await clear()+ await log(f"We are running version {VERSION} of Cyberdrop Downloader", Fore.WHITE)logging.debug(f"Starting downloader with args: {args.__dict__}")input_file = Path(args.input_file)if not os.path.isfile(input_file):Path.touch(input_file)- log(f"{input_file} created. Populate it and retry.")+ await log(f"{input_file} created. Populate it and retry.")exit(1)- conn, curr = sql_initialize()+ conn, curr = await sql_initialize()links = args.linkswith open(input_file, "r") as f:- links += regex_links(f.read())+ links += await regex_links(f.read())content_object = await scrape(links, args.include_id, args.thotsbay_username, args.thotsbay_password)- if content_object.is_empty():+ if await content_object.is_empty():logging.error(f'ValueError No links')- log('No links found, check the URL.txt\nIf the link works in your web browser, '- 'please open an issue ticket with me.', Fore.RED)- log("This program does not currently support password protected albums.", Fore.RED)+ await log('No links found, check the URL.txt\nIf the link works in your web browser, please open an issue ticket with me.', Fore.RED)+ await log("This program does not currently support password protected albums.", Fore.RED)exit(0)- clear()+ await clear()downloaders = get_downloaders(content_object, folder=Path(args.output_folder), attempts=args.attempts,disable_attempt_limit=args.disable_attempt_limit,threads=args.threads, exclude_videos=args.exclude_videos,@@ -69,12 +68,12 @@ async def download_all(args: argparse.Namespace):combined = '\t'.join(all_files)conn.commit()- log('Purging empty directories')- deleted = purge_dir(args.output_folder)+ await log('Purging empty directories')+ deleted = await purge_dir(args.output_folder)- log('Finished downloading. Enjoy :)')+ await log('Finished downloading. Enjoy :)')if '.part' in combined:- log('There are still partial downloads in your folders, please re-run the program.')+ await log('There are still partial downloads in your folders, please re-run the program.')def main():diff --git a/cyberdrop_dl/utils/base_functions.py b/cyberdrop_dl/utils/base_functions.pyindex 456ef3152..521371e0f 100644--- a/cyberdrop_dl/utils/base_functions.py+++ b/cyberdrop_dl/utils/base_functions.py@@ -48,11 +48,11 @@ MAX_FILENAME_LENGTH = 100logger = logging.getLogger(__name__)-def sanitize(input: str) -> str:+async def sanitize(input: str) -> str:return re.sub(r'[<>:"/\\|?*\']', "", input)-def sql_initialize():+async def sql_initialize():download_history = "download_history_size_based.sqlite"conn = sqlite3.connect(download_history)@@ -88,23 +88,23 @@ async def sql_update_file(connection: sqlite3.Connection, cursor: sqlite3.Cursorconnection.commit()-def log(text, style=Fore.WHITE) -> None:+async def log(text, style=Fore.WHITE) -> None:"""Wrapper around print() to add color to text"""logger.debug(text)print(style + str(text) + Style.RESET_ALL)-def clear() -> None:+async def clear() -> None:"""Clears the terminal screen"""os.system('cls' if os.name == 'nt' else 'clear')-def make_title_safe(title: str):+async def make_title_safe(title: str):title = re.sub(r'[\\*?:"<>|./]', "-", title)return title-def purge_dir(dir, in_place=True):+async def purge_dir(dir, in_place=True):deleted = []dir_tree = list(os.walk(dir, topdown=False))@@ -121,16 +121,15 @@ def purge_dir(dir, in_place=True):return deleted-def regex_links(urls) -> list:- all_links = [x.group().replace(".md.", ".") for x in- re.finditer(r"(?:http.*?)(?=('|$|\n|\r\n|\r|\s|\"|\[/URL]))", urls)]+async def regex_links(urls) -> list:+ all_links = [x.group().replace(".md.", ".") for x in re.finditer(r"(?:http.*?)(?=('|$|\n|\r\n|\r|\s|\"|\[/URL]))", urls)]yarl_links = []for link in all_links:yarl_links.append(URL(link))return yarl_links-def bunkr_parse(url: URL) -> URL:+async def bunkr_parse(url: URL) -> URL:"""Fix the URL for bunkr.is."""extension = '.' + str(url).split('.')[-1]if extension.lower() in FILE_FORMATS['Videos']:@@ -142,7 +141,15 @@ def bunkr_parse(url: URL) -> URL:return url-def pixeldrain_parse(url: URL, title: str) -> URL:+async def cyberdrop_parse(url: URL) -> URL:+ mapping_direct = [r'img-...cyberdrop...', r'f.cyberdrop...', r'fs-...cyberdrop...']+ url = str(url)+ for mapping in mapping_direct:+ url = re.sub(mapping, 'cyberdrop.to', url)+ return URL(url)+++async def pixeldrain_parse(url: URL, title: str) -> URL:"""Fix the URL for Pixeldrain"""if url.parts[1] == 'l':final_url = URL('https://pixeldrain.com/api/list/') / title / 'zip'@@ -151,7 +158,7 @@ def pixeldrain_parse(url: URL, title: str) -> URL:return final_url-def check_direct(url: URL):+async def check_direct(url: URL):mapping_direct = ['i.pixl.is', r's..putmega.com', r's..putme.ga', r'img-...cyberdrop...', r'f.cyberdrop...',r'fs-...cyberdrop...', r'cdn.bunkr...', r'media-files.bunkr...', r'jpg.church/images/...',r'stream.bunkr...', r'simp..jpg.church']@@ -164,13 +171,7 @@ def check_direct(url: URL):return False-def unique_list(list1):- list_set = set(list1)- unique = list(list_set)- return unique---def url_sort(urls, Cascade):+async def url_sort(urls, Cascade):ShareX_urls = []Chibisafe_urls = []Erome_urls = []@@ -183,17 +184,17 @@ def url_sort(urls, Cascade):base_domain = "{}.{}".format(url_extract.domain, url_extract.suffix)if base_domain in mapping_ShareX:- if check_direct(url):- Cascade.add_to_album(base_domain, "ShareX Loose Files", url, url)+ if await check_direct(url):+ await Cascade.add_to_album(base_domain, "ShareX Loose Files", url, url)else:ShareX_urls.append(url)elif base_domain in mapping_Chibisafe:- if check_direct(url):+ if await check_direct(url):if 'bunkr' in url.host:- Cascade.add_to_album(base_domain, "Chibisafe Loose Files", bunkr_parse(url), url)+ await Cascade.add_to_album(base_domain, "Chibisafe Loose Files", bunkr_parse(url), url)else:- Cascade.add_to_album(base_domain, "Chibisafe Loose Files", url, url)+ await Cascade.add_to_album(base_domain, "Chibisafe Loose Files", url, url)else:Chibisafe_urls.append(url)@@ -205,7 +206,7 @@ def url_sort(urls, Cascade):elif base_domain in mapping_Pixeldrain:title = str(url).split('/')[-1]- Cascade.add_to_album(base_domain, title, pixeldrain_parse(url, title), url)+ await Cascade.add_to_album(base_domain, title, pixeldrain_parse(url, title), url)elif base_domain in mapping_Anonfiles:Anonfiles_urls.append(url)@@ -214,7 +215,6 @@ def url_sort(urls, Cascade):Thotsbay_urls.append(url)else:- log(str(url) + " is not supported currently.")- logger.debug(str(url) + " is not supported currently.")+ await log(str(url) + " is not supported currently.")return ShareX_urls, Chibisafe_urls, Erome_urls, GoFile_urls, Thotsbay_urls, Anonfiles_urlsdiff --git a/cyberdrop_dl/utils/crawlers/Anonfiles_Spider.py b/cyberdrop_dl/utils/crawlers/Anonfiles_Spider.pyindex 6867eeaeb..501d52cd5 100644--- a/cyberdrop_dl/utils/crawlers/Anonfiles_Spider.py+++ b/cyberdrop_dl/utils/crawlers/Anonfiles_Spider.py@@ -1,6 +1,5 @@from bs4 import BeautifulSoup-from ..base_functions import *from ..data_classes import *@@ -13,7 +12,7 @@ class AnonfilesCrawler():base_domain = "{}.{}".format(url_extract.domain, url_extract.suffix)domain_obj = DomainItem(base_domain, {})- log("Starting scrape of " + str(url), Fore.WHITE)+ await log("Starting scrape of " + str(url), Fore.WHITE)try:async with session.get(url, ssl=ssl_context) as response:@@ -24,12 +23,12 @@ class AnonfilesCrawler():link = soup.select_one("a[id=download-url]")link = URL(link.get('href'))- domain_obj.add_to_album(title, link, url)+ await domain_obj.add_to_album(title, link, url)except Exception as e:logger.debug("Error encountered while handling %s", str(url), exc_info=True)logger.debug(e)- log("Finished scrape of " + str(url), Fore.WHITE)+ await log("Finished scrape of " + str(url), Fore.WHITE)return domain_objdiff --git a/cyberdrop_dl/utils/crawlers/Chibisafe_Spider.py b/cyberdrop_dl/utils/crawlers/Chibisafe_Spider.pyindex 93c9b68bc..3f93a63ba 100644--- a/cyberdrop_dl/utils/crawlers/Chibisafe_Spider.py+++ b/cyberdrop_dl/utils/crawlers/Chibisafe_Spider.py@@ -1,6 +1,5 @@from bs4 import BeautifulSoup-from ..base_functions import *from ..data_classes import *@@ -13,7 +12,7 @@ class ChibisafeCrawler():base_domain = "{}.{}".format(url_extract.domain, url_extract.suffix)domain_obj = DomainItem(base_domain, {})- log("Starting scrape of " + str(url), Fore.WHITE)+ await log("Starting scrape of " + str(url), Fore.WHITE)try:async with session.get(url, ssl=ssl_context) as response:@@ -27,19 +26,21 @@ class ChibisafeCrawler():titlep2 = url.nametitlep2 = [s for s in titlep2 if "." in s][-1]title = title + " - " + titlep2- title = make_title_safe(title.replace(r"\n", "").strip())+ title = await make_title_safe(title.replace(r"\n", "").strip())links = soup.select("a[class=image]")for link in links:link = URL(link.get('href'))if 'bunkr' in link.host:- link = bunkr_parse(link)- domain_obj.add_to_album(title, link, url)+ link = await bunkr_parse(link)+ elif 'cyberdrop' in link.host:+ link = await cyberdrop_parse(link)+ await domain_obj.add_to_album(title, link, url)except Exception as e:logger.debug("Error encountered while handling %s", str(url), exc_info=True)logger.debug(e)- log("Finished scrape of " + str(url), Fore.WHITE)+ await log("Finished scrape of " + str(url), Fore.WHITE)return domain_objdiff --git a/cyberdrop_dl/utils/crawlers/Erome_Spider.py b/cyberdrop_dl/utils/crawlers/Erome_Spider.pyindex f65fa3e21..8914fb110 100644--- a/cyberdrop_dl/utils/crawlers/Erome_Spider.py+++ b/cyberdrop_dl/utils/crawlers/Erome_Spider.py@@ -1,6 +1,5 @@from bs4 import BeautifulSoup-from ..base_functions import *from ..data_classes import *@@ -13,7 +12,7 @@ class EromeCrawler():base_domain = "{}.{}".format(url_extract.domain, url_extract.suffix)domain_obj = DomainItem(base_domain, {})- log("Starting scrape of " + str(url), Fore.WHITE)+ await log("Starting scrape of " + str(url), Fore.WHITE)try:async with session.get(url, ssl=ssl_context) as response:@@ -26,20 +25,20 @@ class EromeCrawler():title = url.nameelif self.include_id:title = title + " - " + url.name- title = make_title_safe(title)+ title = await make_title_safe(title)# Imagesfor link in soup.select('img[class="img-front lasyload"]'):- domain_obj.add_to_album(title, URL(link['data-src']), url)+ await domain_obj.add_to_album(title, URL(link['data-src']), url)# Videosfor link in soup.select('div[class=media-group] div[class=video-lg] video source'):- domain_obj.add_to_album(title, URL(link['src']), url)+ await domain_obj.add_to_album(title, URL(link['src']), url)except Exception as e:logger.debug("Error encountered while handling %s", str(url), exc_info=True)logger.debug(e)- log("Finished scrape of " + str(url), Fore.WHITE)+ await log("Finished scrape of " + str(url), Fore.WHITE)return domain_objdiff --git a/cyberdrop_dl/utils/crawlers/GoFile_Spider.py b/cyberdrop_dl/utils/crawlers/GoFile_Spider.pyindex 654359bf6..76ad598fa 100644--- a/cyberdrop_dl/utils/crawlers/GoFile_Spider.py+++ b/cyberdrop_dl/utils/crawlers/GoFile_Spider.py@@ -23,14 +23,14 @@ class GofileCrawler():results = await self.get_links(url)- log("Starting scrape of " + str(url), Fore.WHITE)+ await log("Starting scrape of " + str(url), Fore.WHITE)logging.debug("Starting scrape of " + str(url))if results:for result in results:- domain_obj.add_to_album(result['title'], result['url'], result['referral'])+ await domain_obj.add_to_album(result['title'], result['url'], result['referral'])- log("Finished scrape of " + str(url), Fore.WHITE)+ await log("Finished scrape of " + str(url), Fore.WHITE)return domain_obj@@ -40,7 +40,7 @@ class GofileCrawler():try:content = self.client.get_content(content_id)except:- log("GoFile seems to be down.")+ await log("GoFile seems to be down.")logging.debug("GoFile seems to be down or the link is dead")returnif not content:diff --git a/cyberdrop_dl/utils/crawlers/ShareX_Spider.py b/cyberdrop_dl/utils/crawlers/ShareX_Spider.pyindex 9f393e8dc..e4a62580a 100644--- a/cyberdrop_dl/utils/crawlers/ShareX_Spider.py+++ b/cyberdrop_dl/utils/crawlers/ShareX_Spider.py@@ -13,7 +13,7 @@ class ShareXCrawler():base_domain = "{}.{}".format(url_extract.domain, url_extract.suffix)domain_obj = DomainItem(base_domain, {})- log("Starting scrape of " + str(url), Fore.WHITE)+ await log("Starting scrape of " + str(url), Fore.WHITE)if "album" in url.parts or "a" in url.parts:results = await self.parse(url, session)@@ -23,10 +23,11 @@ class ShareXCrawler():results = await self.get_singular(url, session)else:results = await self.parse_profile(url, session)+for result in results:- domain_obj.add_to_album(result['title'], result['url'], result['referral'])+ await domain_obj.add_to_album(result['title'], result['url'], result['referral'])- log("Finished scrape of " + str(url), Fore.WHITE)+ await log("Finished scrape of " + str(url), Fore.WHITE)return domain_obj@@ -89,7 +90,7 @@ class ShareXCrawler():elif self.include_id:titlep2 = url.nametitle = title + " - " + titlep2- title = make_title_safe(title.replace(r"\n", "").strip())+ title = await make_title_safe(title.replace(r"\n", "").strip())list_recent = URL(soup.select_one("a[id=list-most-recent-link]").get('href'))results.extend(result for result in await self.get_list_links(list_recent, session, title))@@ -136,7 +137,7 @@ class ShareXCrawler():elif self.include_id:titlep2 = url.nametitle = title + " - " + titlep2- title = make_title_safe(title.replace(r"\n", "").strip())+ title = await make_title_safe(title.replace(r"\n", "").strip())if og_title is not None:title = og_title + "/" + titlediff --git a/cyberdrop_dl/utils/crawlers/Thotsbay_Spider.py b/cyberdrop_dl/utils/crawlers/Thotsbay_Spider.pyindex d8e0d0589..4f72b2c8b 100644--- a/cyberdrop_dl/utils/crawlers/Thotsbay_Spider.py+++ b/cyberdrop_dl/utils/crawlers/Thotsbay_Spider.py@@ -40,29 +40,30 @@ class ThotsbayCrawler():async def fetch(self, session, url):Cascade = CascadeItem({})- log("Starting scrape of " + str(url), Fore.WHITE)+ await log("Starting scrape of " + str(url), Fore.WHITE)if self.username and self.password:await self.login(session)else:- log("login wasn't provided, consider using --thotsbay-username and --thotsbay-password")- log("Not being logged in might cause issues.")+ await log("login wasn't provided, consider using --thotsbay-username and --thotsbay-password")+ await log("Not being logged in might cause issues.")try:ShareX_urls, Chibisafe_urls, Erome_urls, GoFile_urls, Thotsbay_urls, Anonfile_urls, title = await self.parse(session, url, Cascade, None)except:- log("Error handling " + str(url))+ await log("Error handling " + str(url))return+tasks = []for url in Erome_urls:tasks.append(self.erome_crawler.fetch(session, url))for url in ShareX_urls:- if check_direct(url):- Cascade.add_to_album(url.host, "ShareX Loose Files", url, url)+ if await check_direct(url):+ await Cascade.add_to_album(url.host, "ShareX Loose Files", url, url)tasks.append(self.sharex_crawler.fetch(session, url))for url in Chibisafe_urls:- if check_direct(url):- Cascade.add_to_album(url.host, "Chibisafe Loose Files", url, url)+ if await check_direct(url):+ await Cascade.add_to_album(url.host, "Chibisafe Loose Files", url, url)tasks.append(self.chibisafe_crawler.fetch(session, url))for url in GoFile_urls:tasks.append(self.gofile_crawler.fetch(session, url))@@ -71,12 +72,10 @@ class ThotsbayCrawler():results = await asyncio.gather(*tasks)for result in results:- Cascade.add_albums(result)-- Cascade.append_title(title)-- log("Finished scrape of " + str(url), Fore.WHITE)+ await Cascade.add_albums(result)+ await Cascade.append_title(title)+ await log("Finished scrape of " + str(url), Fore.WHITE)return Cascadeasync def parse(self, session, url, Cascade, title):@@ -93,7 +92,7 @@ class ThotsbayCrawler():titlep2 = url.nametitlep2 = [s for s in titlep2 if "." in s][-1]title = title + " - " + titlep2- title = make_title_safe(title.replace(r"\n", "").strip())+ title = await make_title_safe(title.replace(r"\n", "").strip())content_links = []@@ -145,17 +144,17 @@ class ThotsbayCrawler():link = link[:-1]if link.startswith('/'):link = URL("https://forum.thotsbay.com") / link[1:]- Cascade.add_to_album("Thotsbay.com", "Attachments", link, url)+ await Cascade.add_to_album("Thotsbay.com", "Attachments", link, url)- ShareX_urls, Chibisafe_urls, Erome_urls, GoFile_urls, Thotsbay_urls, Anonfile_urls = url_sort(content_links, Cascade)+ ShareX_urls, Chibisafe_urls, Erome_urls, GoFile_urls, Thotsbay_urls, Anonfile_urls = await url_sort(content_links, Cascade)for link in Thotsbay_urls:if str(link).endswith("/"):link = URL(str(link)[:-1])if 'attachments' in link.parts:- Cascade.add_to_album("Thotsbay.com", "Attachments", link, url)+ await Cascade.add_to_album("Thotsbay.com", "Attachments", link, url)elif 'data' in link.parts:- Cascade.add_to_album("Thotsbay.com", "Attachments", link, url)+ await Cascade.add_to_album("Thotsbay.com", "Attachments", link, url)next_page = soup.select_one('a[class="pageNav-jump pageNav-jump--next"]')if next_page is not None:diff --git a/cyberdrop_dl/utils/data_classes.py b/cyberdrop_dl/utils/data_classes.pyindex 5a493efd0..710cd0ca8 100644--- a/cyberdrop_dl/utils/data_classes.py+++ b/cyberdrop_dl/utils/data_classes.py@@ -3,7 +3,7 @@ from typing import Optional, List, Dict, Tuple, AnyStr, Anyimport aiohttp-from .base_functions import*+from .base_functions import *@dataclass@@ -13,10 +13,10 @@ class AlbumItem:link_pairs: List[Tuple]password: Optional[str] = None- def add_link_pair(self, link, referral):+ async def add_link_pair(self, link, referral):self.link_pairs.append((link, referral))- def set_new_title(self, new_title: str):+ async def set_new_title(self, new_title: str):self.title = new_title@@ -25,18 +25,18 @@ class DomainItem:domain: stralbums: Dict[str, AlbumItem]- def add_to_album(self, title: str, link: URL, referral: URL):+ async def add_to_album(self, title: str, link: URL, referral: URL):if title in self.albums.keys():- self.albums[title].add_link_pair(link, referral)+ await self.albums[title].add_link_pair(link, referral)else:self.albums[title] = AlbumItem(title=title, link_pairs=[(link, referral)])- def add_album(self, title: str, album: AlbumItem):+ async def add_album(self, title: str, album: AlbumItem):if title in self.albums.keys():stored_album = self.albums[title]for link_pair in album.link_pairs:link, referral = link_pair- stored_album.add_link_pair(link, referral)+ await stored_album.add_link_pair(link, referral)else:self.albums[title] = album@@ -47,32 +47,32 @@ class CascadeItem:domains: Dict[str, DomainItem]cookies: aiohttp.CookieJar = None- def add_albums(self, domain_item: DomainItem):+ async def add_albums(self, domain_item: DomainItem):domain = domain_item.domainalbums = domain_item.albumsfor title, album in albums.items():- self.add_album(domain, title, album)+ await self.add_album(domain, title, album)- def add_to_album(self, domain: str, title: str, link: URL, referral: URL):+ async def add_to_album(self, domain: str, title: str, link: URL, referral: URL):if domain in self.domains.keys():- self.domains[domain].add_to_album(title, link, referral)+ await self.domains[domain].add_to_album(title, link, referral)else:self.domains[domain] = DomainItem(domain, {title: AlbumItem(title, [(link, referral)])})- def add_album(self, domain: str, title: str, album: AlbumItem):+ async def add_album(self, domain: str, title: str, album: AlbumItem):if domain in self.domains.keys():- self.domains[domain].add_album(title, album)+ await self.domains[domain].add_album(title, album)else:self.domains[domain] = DomainItem(domain, {title: album})- def is_empty(self):+ async def is_empty(self):for domain_str, domain in self.domains.items():for album_str, album in domain.albums.items():if album.link_pairs:return Falsereturn True- def append_title(self, title):+ async def append_title(self, title):for domain_str, domain in self.domains.items():new_albums = {}for album_str, album in domain.albums.items():@@ -81,13 +81,13 @@ class CascadeItem:album.title = new_titledomain.albums = new_albums- def extend(self, Cascade):+ async def extend(self, Cascade):if Cascade.domains:for domain_str, domain in Cascade.domains.items():for album_str, album in domain.albums.items():- self.add_album(domain_str, album_str, album)+ await self.add_album(domain_str, album_str, album)- def dedupe(self):+ async def dedupe(self):for domain_str, domain in self.domains.items():for album_str, album in domain.albums.items():check = []diff --git a/cyberdrop_dl/utils/downloaders.py b/cyberdrop_dl/utils/downloaders.pyindex 8db70a8fa..5a7754291 100644--- a/cyberdrop_dl/utils/downloaders.py+++ b/cyberdrop_dl/utils/downloaders.py@@ -111,7 +111,7 @@ class Downloader:if not (ext in FILE_FORMATS['Images'] or ext in FILE_FORMATS['Videos'] or ext in FILE_FORMATS['Audio'] or ext in FILE_FORMATS['Other']):async with session.get(url, headers=headers, ssl=ssl_context, raise_for_status=True) as resp:filename = resp.content_disposition.filename- filename = sanitize(filename)+ filename = await sanitize(filename)del respif (self.folder / self.title / filename).exists():return@@ -146,12 +146,12 @@ class Downloader:async with session.get(url, headers=headers, ssl=ssl_context, raise_for_status=True) as resp:content_type = resp.headers.get('Content-Type')if 'text' in content_type.lower() or 'html' in content_type.lower():- log(f"\nServer for {url} is either down or the file no longer exists\n", Fore.RED)+ await log(f"\nServer for {url} is either down or the file no longer exists\n", Fore.RED)returntotal = int(resp.headers.get('Content-Length', str(0))) + resume_pointif await sql_check_existing(self.cursor, filename, total):- log("\n%s Already Downloaded\n" % filename)+ await log("\n%s Already Downloaded\n" % filename)returnawait sql_insert_file(self.connection, self.cursor, filename, total, 0)@@ -172,12 +172,11 @@ class Downloader:aiohttp.client_exceptions.ClientResponseError, FailureException) as e:try:if 400 <= e.code < 500:- log("We ran into a 400 level error")+ await log("\nWe ran into a 400 level error: %s\n" % str(e.code))returnresp.close()except:pass-raise FailureException(e)async def rename_file(self, filename: str) -> None:@@ -202,7 +201,7 @@ class Downloader:url, referral = url_tuplefilename = url.name- filename = sanitize(filename)+ filename = await sanitize(filename)if "v=" in filename:filename = filename.split('v=')[0]if len(filename) > MAX_FILENAME_LENGTH:@@ -212,7 +211,6 @@ class Downloader:complete_file = (self.folder / self.title / filename)if complete_file.exists():await sql_update_file(self.connection, self.cursor, filename, complete_file.stat().st_size, 1)-logger.debug(str(complete_file) + " Already Exists")else:logger.debug("Working on " + str(url))@@ -221,7 +219,7 @@ class Downloader:session=session, show_progress=show_progress)except Exception:logger.debug(traceback.format_exc())- log(f"\nError attempting {filename}: See downloader.log for details\n", Fore.WHITE)+ await log(f"\nError attempting {filename}: See downloader.log for details\n", Fore.WHITE)async def download_all(self,@@ -235,10 +233,7 @@ class Downloader:for func in tqdm(asyncio.as_completed(coros), total=len(coros), desc=self.title, unit='FILES'):await func- async def download_content(- self,- show_progress: bool = True- ) -> None:+ async def download_content(self, show_progress: bool = True) -> None:"""Download the content of all links and save them as files."""(self.folder / self.title).mkdir(parents=True, exist_ok=True)async with aiohttp.ClientSession(cookie_jar=self.cookie_jar) as session:diff --git a/cyberdrop_dl/utils/scraper.py b/cyberdrop_dl/utils/scraper.pyindex 1d1a48521..1ab72d7ff 100644--- a/cyberdrop_dl/utils/scraper.py+++ b/cyberdrop_dl/utils/scraper.py@@ -13,9 +13,9 @@ from .base_functions import *async def scrape(urls, include_id: bool, thotsbay_username: str, thotsbay_password: str):Cascade = CascadeItem({})- log("Starting Scrape", Fore.WHITE)+ await log("Starting Scrape", Fore.WHITE)- ShareX_urls, Chibisafe_urls, Erome_urls, GoFile_urls, Thotsbay_urls, Anonfile_urls = url_sort(urls, Cascade)+ ShareX_urls, Chibisafe_urls, Erome_urls, GoFile_urls, Thotsbay_urls, Anonfile_urls = await url_sort(urls, Cascade)erome_crawler = EromeCrawler(include_id=include_id)sharex_crawler = ShareXCrawler(include_id=include_id)@@ -46,7 +46,7 @@ async def scrape(urls, include_id: bool, thotsbay_username: str, thotsbay_passworesults = await asyncio.gather(*tasks)for domain_item in results:- Cascade.add_albums(domain_item)+ await Cascade.add_albums(domain_item)# Returns a Cascade itemresults = []@@ -56,8 +56,8 @@ async def scrape(urls, include_id: bool, thotsbay_username: str, thotsbay_passwofor result in results:if result:if result.domains:- Cascade.extend(result)+ await Cascade.extend(result)Cascade.cookies = jar- Cascade.dedupe()+ await Cascade.dedupe()return Cascade