Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Code re-organization
Jules-WinnfieldX7611a438a5ce
diff --git a/README.md b/README.mdindex 52602eafd..f05f2577f 100644--- a/README.md+++ b/README.md@@ -1,7 +1,7 @@# `cyberdrop-dl`**Bulk downloader for multiple file hosts**-The latest version of the program is 3.4.25+The latest version of the program is 3.4.26<a href="https://www.buymeacoffee.com/juleswinnft" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>diff --git a/changelog.txt b/changelog.txtindex 6f5483c0a..4699bc272 100644--- a/changelog.txt+++ b/changelog.txt@@ -30,4 +30,7 @@- Fix bunkr images3.4.25-- add pdf support\ No newline at end of file+- add pdf support++3.4.26+- code reorganization\ No newline at end of filediff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.pyindex 088da17ed..1fb8066b0 100644--- a/cyberdrop_dl/__init__.py+++ b/cyberdrop_dl/__init__.py@@ -1 +1 @@-__version__ = "3.4.25"+__version__ = "3.4.26"diff --git a/cyberdrop_dl/base_functions/base_functions.py b/cyberdrop_dl/base_functions/base_functions.pyindex f6315b2a3..549f4d3f9 100644--- a/cyberdrop_dl/base_functions/base_functions.py+++ b/cyberdrop_dl/base_functions/base_functions.py@@ -32,7 +32,7 @@ FILE_FORMATS = {},'Other': {'.json', '.torrent', '.zip', '.rar',- '.7z', '.torrent', '.psd', 'pdf',+ '.7z', '.torrent', '.psd', '.pdf',}}diff --git a/cyberdrop_dl/base_functions/config_schema.py b/cyberdrop_dl/base_functions/config_schema.pyindex f0ad099d4..36438edcb 100644--- a/cyberdrop_dl/base_functions/config_schema.py+++ b/cyberdrop_dl/base_functions/config_schema.py@@ -5,6 +5,7 @@ config_default = ["Files": {"input_file": "URLs.txt","output_folder": "Downloads",+ "output_last_forum_post_file": "URLs_last_post.txt","db_file": "download_history.sqlite",},"Authentication": {@@ -36,6 +37,7 @@ config_default = ["ignore_history": False,"output_last_forum_post": False,"separate_posts": False,+ "mark_downloaded": False,"proxy": "","skip_hosts": [],}@@ -43,11 +45,11 @@ config_default = [}]-files_args = ["input_file", "output_folder", "db_file"]+files_args = ["input_file", "output_folder", "output_last_forum_post_file", "db_file"]authentication_args = ["simpcity_username", "simpcity_password","socialmediagirls_username", "socialmediagirls_password","xbunker_username", "xbunker_password"]jdownloader_args = ["jdownloader_enable", "jdownloader_username", "jdownloader_password", "jdownloader_device"]runtime_args = ["threads", "attempts", "disable_attempt_limit", "connection_timeout", "ratelimit", "throttle","include_id", "exclude_videos", "exclude_images", "exclude_audio", "exclude_other", "ignore_history",- "output_last_forum_post", "separate_posts", "skip_hosts", "proxy"]+ "output_last_forum_post", "mark_downloaded", "separate_posts", "skip_hosts", "proxy"]diff --git a/cyberdrop_dl/client/client.py b/cyberdrop_dl/client/client.pyindex 544ddce26..d37bab6ae 100644--- a/cyberdrop_dl/client/client.py+++ b/cyberdrop_dl/client/client.py@@ -126,12 +126,12 @@ class DownloadSession:content_type = resp.headers.get('Content-Type')return content_type.lower()- async def download_file(self, url: URL, referer: str, current_throttle: int, range: str, original_filename: str,+ async def download_file(self, url: URL, referer: str, current_throttle: int, range_num: str, original_filename: str,filename: str, temp_file: str, resume_point: int, show_progress: bool,File_Lock: FileLock, folder: Path, title: str, proxy: str):headers = {'Referer': referer, 'user-agent': self.client.user_agent}- if range:- headers['Range'] = range+ if range_num:+ headers['Range'] = range_numawait throttle(self, current_throttle, url.host)async with self.client_session.get(url, headers=headers, ssl=self.client.ssl_context,raise_for_status=True, proxy=proxy) as resp:diff --git a/cyberdrop_dl/client/downloaders.py b/cyberdrop_dl/client/downloaders.pyindex 477fbd7d8..ce8214a51 100644--- a/cyberdrop_dl/client/downloaders.py+++ b/cyberdrop_dl/client/downloaders.py@@ -47,20 +47,20 @@ def retry(f):class Downloader:- def __init__(self, album_obj: AlbumItem, folder: Path, title: str, attempts: int,- disable_attempt_limit: bool, max_workers: int, excludes: Dict[str, bool], SQL_helper: SQLHelper,- client: Client, proxy: str):+ def __init__(self, album_obj: AlbumItem, title: str, max_workers: int, excludes: Dict[str, bool],+ SQL_helper: SQLHelper, client: Client, file_args: Dict, runtime_args: Dict):self.album_obj = album_objself.client = client- self.folder = folder+ self.folder = file_args['output_folder']self.title = titleself.SQL_helper = SQL_helperself.File_Lock = FileLock()- self.attempts = attempts+ self.attempts = runtime_args['attempts']self.current_attempt = {}- self.disable_attempt_limit = disable_attempt_limit+ self.disable_attempt_limit = runtime_args['disable_attempt_limit']+ self.mark_downloaded = runtime_args['mark_downloaded']self.excludes = excludes@@ -68,7 +68,7 @@ class Downloader:self._semaphore = asyncio.Semaphore(max_workers)self.delay = {'cyberfile.is': 1, 'anonfiles.com': 1}- self.proxy = proxy+ self.proxy = runtime_args['proxy']"""Changed from aiohttp exceptions caught to FailureException to allow for partial downloads."""@@ -81,6 +81,7 @@ class Downloader:referer = str(referral)db_path = url.path+ current_throttle = self.client.throttleif 'anonfiles' in url.host:db_path = db_path.split('/')@@ -95,59 +96,10 @@ class Downloader:try:async with self._semaphore:- # If ext isn't allowable we likely have an invalid filename, lets go get it.- ext = '.' + filename.split('.')[-1].lower()- current_throttle = self.client.throttle- 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']):- for key, value in self.delay.items():- if key in url.host:- if value > current_throttle:- current_throttle = value- try:- filename = await session.get_filename(url, referer, current_throttle)- filename = await sanitize(filename)- ext = '.' + filename.split('.')[-1].lower()- 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']):- await log("\nNo file extension on content in link: " + str(url))- return- except:- try:- content_type = await session.get_content_type(url, referer, current_throttle)- if "image" in content_type:- ext_temp = content_type.split('/')[-1]- filename = filename + '.' + ext_temp- filename = await sanitize(filename)- else:- await log("\nUnhandled content_type for checking filename: " + content_type)- raise- except:- await log("\nCouldn't get filename for: " + str(url))- return-# Make suffix always lower case- ext = '.' + filename.split('.')[-1].lower()- filename = filename.replace('.' + filename.split('.')[-1], ext)-- # Skip based on CLI arg.- if self.excludes['videos']:- if ext in FILE_FORMATS['Videos']:- logging.debug("Skipping " + filename)- return- if self.excludes['images']:- if ext in FILE_FORMATS['Images']:- logging.debug("Skipping " + filename)- return- if self.excludes['audio']:- if ext in FILE_FORMATS['Audio']:- logging.debug("Skipping " + filename)- return- if self.excludes['other']:- if ext in FILE_FORMATS['Other']:- logging.debug("Skipping " + filename)- return-original_filename = filename+ ext = '.' + filename.split('.')[-1]+while await self.File_Lock.check_lock(filename):await asyncio.sleep(gauss(1, 1.5))await self.File_Lock.add_lock(filename)@@ -179,22 +131,26 @@ class Downloader:await self.SQL_helper.sql_insert_file(db_path, filename, 0)+ if self.mark_downloaded:+ await self.SQL_helper.sql_update_file(db_path, filename, 1)+ return+complete_file = (self.folder / self.title / filename)temp_file = complete_file.with_suffix(complete_file.suffix + '.part')resume_point = 0await self.SQL_helper.sql_insert_temp(str(temp_file))- range = None+ range_num = Noneif temp_file.exists():resume_point = temp_file.stat().st_size- range = f'bytes={resume_point}-'+ range_num = f'bytes={resume_point}-'for key, value in self.delay.items():if key in url.host:current_throttle = value- await session.download_file(url, referer, current_throttle, range, original_filename, filename,+ await session.download_file(url, referer, current_throttle, range_num, original_filename, filename,temp_file, resume_point, show_progress, self.File_Lock, self.folder,self.title, self.proxy)@@ -237,9 +193,9 @@ class Downloader:await self.SQL_helper.sql_update_file(db_path, filename, 1)logger.debug("Finished " + filename)- async def download_and_store(self, url_tuple: Tuple, session: DownloadSession, show_progress: bool = True) -> None:- """Download the content of given URL and store it in a file."""- url, referral = url_tuple+ async def get_filename(self, url: URL, referral: URL, session: DownloadSession):+ """Does all the necessary work to try and figure out what exactly the Filename should be."""+ referer = str(referral)filename = url.namefilename = await sanitize(filename)@@ -249,13 +205,73 @@ class Downloader:fileext = filename.split('.')[-1]filename = filename[:MAX_FILENAME_LENGTH] + '.' + fileext+ ext = '.' + filename.split('.')[-1].lower()+ current_throttle = self.client.throttle+ 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']):+ for key, value in self.delay.items():+ if key in url.host:+ if value > current_throttle:+ current_throttle = value+ try:+ filename = await session.get_filename(url, referer, current_throttle)+ filename = await sanitize(filename)+ ext = '.' + filename.split('.')[-1].lower()+ 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']):+ logging.debug("No file extension on content in link: " + str(url))+ raise FailureException(0)+ except FailureException:+ try:+ content_type = await session.get_content_type(url, referer, current_throttle)+ if "image" in content_type:+ ext_temp = content_type.split('/')[-1]+ filename = filename + '.' + ext_temp+ filename = await sanitize(filename)+ else:+ logging.debug("\nUnhandled content_type for checking filename: " + content_type)+ raise FailureException(0)+ except FailureException:+ await log("\nCouldn't get filename for: " + str(url))+ raise FailureException(0)++ ext = '.' + filename.split('.')[-1].lower()+ filename = filename.replace('.' + filename.split('.')[-1], ext)+ return filename++ async def check_exclude(self, filename):+ """Check the exclude arguments to see if this file should be skipped (False)."""+ ext = '.' + filename.split('.')[-1]+ if self.excludes['videos']:+ if ext in FILE_FORMATS['Videos']:+ logging.debug("Skipping " + filename)+ return False+ if self.excludes['images']:+ if ext in FILE_FORMATS['Images']:+ logging.debug("Skipping " + filename)+ return False+ if self.excludes['audio']:+ if ext in FILE_FORMATS['Audio']:+ logging.debug("Skipping " + filename)+ return False+ if self.excludes['other']:+ if ext in FILE_FORMATS['Other']:+ logging.debug("Skipping " + filename)+ return False+ return True++ async def download_and_store(self, url_tuple: Tuple, session: DownloadSession, show_progress: bool = True) -> None:+ """Download the content of given URL and store it in a file."""+ url, referral = url_tuple+logger.debug("Working on " + str(url))try:- await self.download_file(url, referral=referral, filename=filename, session=session,- show_progress=show_progress)+ filename = await self.get_filename(url, referral, session)+ if await self.check_exclude(filename):+ await self.download_file(url, referral=referral, filename=filename, session=session,+ show_progress=show_progress)except Exception:- logger.debug(traceback.format_exc())- await log(f"\nError attempting {filename}: See downloader.log for details\n")+ await log(f"Error attempting {url}")async def download_all(self, album_obj: AlbumItem, session: DownloadSession, show_progress: bool = True) -> None:"""Download the data from all given links and store them into corresponding files."""@@ -271,15 +287,9 @@ class Downloader:self.SQL_helper.conn.commit()-async def get_downloaders(Cascade: CascadeItem, folder: Path, attempts: int, disable_attempt_limit: bool,- max_workers: int, excludes: Dict[str, bool], SQL_helper: SQLHelper, client: Client, proxy: str) -> List[Downloader]:- """Get a list of downloaders for each supported type of URLs.- We shouldn't just assume that each URL will have the same netloc as- the first one, so we need to classify them one by one, sort them to- corresponding netloc URLs and create downloaders separately for individual- netloc URLs they support.- """-+async def get_downloaders(Cascade: CascadeItem, excludes: Dict[str, bool], SQL_helper: SQLHelper, client: Client,+ max_workers: int, file_args: Dict, runtime_args: Dict) -> List[Downloader]:+ """Get a list of downloader objects to run."""downloaders = []for domain, domain_obj in Cascade.domains.items():@@ -287,8 +297,8 @@ async def get_downloaders(Cascade: CascadeItem, folder: Path, attempts: int, disif 'bunkr' in domain or 'pixeldrain' in domain or 'anonfiles' in domain:max_workers_temp = 2 if (max_workers > 2) else max_workersfor title, album_obj in domain_obj.albums.items():- downloader = Downloader(album_obj, title=title, folder=folder, attempts=attempts,- disable_attempt_limit=disable_attempt_limit, max_workers=max_workers_temp,- excludes=excludes, SQL_helper=SQL_helper, client=client, proxy=proxy)+ downloader = Downloader(album_obj, title=title, max_workers=max_workers_temp, excludes=excludes,+ SQL_helper=SQL_helper, client=client,+ file_args=file_args, runtime_args=runtime_args)downloaders.append(downloader)return downloadersdiff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.pyindex 51c6dfb0b..f580212d9 100644--- a/cyberdrop_dl/main.py+++ b/cyberdrop_dl/main.py@@ -5,6 +5,7 @@ import asyncioimport loggingfrom pathlib import Pathfrom functools import wraps+from typing import Dictfrom colorama import Forefrom yarl import URL@@ -40,6 +41,7 @@ def parse_args():parser.add_argument("--output-last-forum-post", help="Separates forum scraping into folders by post number", action="store_true")parser.add_argument("--proxy", help="HTTP/HTTPS proxy used for downloading, format [protocal]://[ip]:[port]", default=None)parser.add_argument("--separate-posts", help="Separates forum scraping into folders by post number", action="store_true")+ parser.add_argument("--mark-downloaded", help="Sets the scraped files as downloaded without downloading", action="store_true")parser.add_argument("--xbunker-username", type=str, help="username to login to xbunker", default=None)parser.add_argument("--xbunker-password", type=str, help="password to login to xbunker", default=None)parser.add_argument("--socialmediagirls-username", type=str, help="username to login to socialmediagirls", default=None)@@ -58,9 +60,7 @@ def parse_args():return args-async def download_all(args: argparse.Namespace):- await clear()- await log(f"We are running version {VERSION} of Cyberdrop Downloader", Fore.WHITE)+async def handle_args(args: argparse.Namespace):print_args = Namespace(**vars(args)).__dict__print_args['xbunker_password'] = '!REDACTED!'print_args['socialmediagirls_password'] = '!REDACTED!'@@ -93,6 +93,45 @@ async def download_all(args: argparse.Namespace):logging.debug(f"Using jdownloader arguments: {jdownloader_args}")logging.debug(f"Using runtime arguments: {runtime_args}")+ return auth_args, file_args, jdownloader_args, runtime_args+++async def download_all(auth_args: Dict, file_args: Dict, jdownloader_args: Dict, runtime_args: Dict, links: list,+ client: Client, SQL_helper: SQLHelper, threads: int):+ xbunker_auth = AuthData(auth_args['xbunker_username'], auth_args['xbunker_password'])+ socialmediagirls_auth = AuthData(auth_args['socialmediagirls_username'], auth_args['socialmediagirls_password'])+ simpcity_auth = AuthData(auth_args['simpcity_username'], auth_args['simpcity_password'])+ jdownloader_auth = AuthData(jdownloader_args['jdownloader_username'], jdownloader_args['jdownloader_password'])++ skip_data = SkipData(runtime_args['skip_hosts'])+ excludes = {'videos': runtime_args['exclude_videos'], 'images': runtime_args['exclude_images'],+ 'audio': runtime_args['exclude_audio'], 'other': runtime_args['exclude_other']}++ content_object = await scrape(urls=links, client=client, file_args=file_args, jdownloader_args=jdownloader_args,+ runtime_args=runtime_args, jdownloader_auth=jdownloader_auth,+ simpcity_auth=simpcity_auth, socialmediagirls_auth=socialmediagirls_auth,+ xbunker_auth=xbunker_auth, skip_data=skip_data)++ if await content_object.is_empty():+ logging.error('ValueError No links')+ await log("No links found duing scraping, check passwords or that the urls are accessible", Fore.RED)+ await log("This program does not currently support password protected albums.", Fore.RED)+ exit(0)+ await clear()++ downloaders = await get_downloaders(content_object, excludes=excludes, SQL_helper=SQL_helper, client=client,+ max_workers=threads, file_args=file_args, runtime_args=runtime_args)++ for downloader in downloaders:+ await downloader.download_content()+++async def director(args: argparse.Namespace):+ await clear()+ await log(f"We are running version {VERSION} of Cyberdrop Downloader", Fore.WHITE)++ auth_args, file_args, jdownloader_args, runtime_args = await handle_args(args)+input_file = file_args['input_file']if not input_file.is_file():input_file.touch()@@ -110,48 +149,21 @@ async def download_all(args: argparse.Namespace):with open(input_file, "r", encoding="utf8") as f:links += await regex_links(f.read())-links = list(filter(None, links))if not links: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)- output_url_file = None-if runtime_args['output_last_forum_post']:- output_url_file: Path = input_file.parent / "URLs_last_post.txt"+ output_url_file = file_args['output_last_forum_post_file']if output_url_file.exists():output_url_file.unlink()output_url_file.touch()- xbunker_auth = AuthData(auth_args['xbunker_username'], auth_args['xbunker_password'])- socialmediagirls_auth = AuthData(auth_args['socialmediagirls_username'], auth_args['socialmediagirls_password'])- simpcity_auth = AuthData(auth_args['simpcity_username'], auth_args['simpcity_password'])- jdownloader_auth = AuthData(jdownloader_args['jdownloader_username'], jdownloader_args['jdownloader_password'])- skip_data = SkipData(runtime_args['skip_hosts'])- excludes = {'videos': runtime_args['exclude_videos'], 'images': runtime_args['exclude_images'],- 'audio': runtime_args['exclude_audio'], 'other': runtime_args['exclude_other']}- content_object = await scrape(links, client, runtime_args['include_id'], jdownloader_args['jdownloader_enable'],- jdownloader_args['jdownloader_device'], xbunker_auth, socialmediagirls_auth,- simpcity_auth, jdownloader_auth, runtime_args['separate_posts'], skip_data,- [runtime_args['output_last_forum_post'], output_url_file])-- if await content_object.is_empty():- logging.error('ValueError No links')- await log("No links found duing scraping, check passwords or that the urls are accessible", Fore.RED)- await log("This program does not currently support password protected albums.", Fore.RED)- exit(0)- await clear()-- downloaders = await get_downloaders(content_object, folder=file_args['output_folder'],- attempts=runtime_args['attempts'],- disable_attempt_limit=runtime_args['disable_attempt_limit'],- max_workers=threads, excludes=excludes, SQL_helper=SQL_helper, client=client,- proxy=runtime_args['proxy'])+ await download_all(auth_args=auth_args, file_args=file_args, jdownloader_args=jdownloader_args,+ runtime_args=runtime_args, links=links, client=client, SQL_helper=SQL_helper, threads=threads)- for downloader in downloaders:- await downloader.download_content(conn_timeout=runtime_args['connection_timeout'])logger.debug("Finished")partial_downloads = [str(f) for f in file_args['output_folder'].rglob("*.part") if f.is_file()]@@ -167,17 +179,6 @@ async def download_all(args: argparse.Namespace):await log('There are partial downloads from this run, please re-run the program.')-def silence_event_loop_closed(func):- @wraps(func)- def wrapper(self, *args, **kwargs):- try:- return func(self, *args, **kwargs)- except RuntimeError as e:- if str(e) != 'Event loop is closed':- raise- return wrapper--def main(args=None):if not args:args = parse_args()@@ -190,7 +191,7 @@ def main(args=None):try:loop = asyncio.get_event_loop()- loop.run_until_complete(download_all(args))+ loop.run_until_complete(director(args))loop.run_until_complete(asyncio.sleep(5))loop.close()except RuntimeError:@@ -198,8 +199,6 @@ def main(args=None):if __name__ == '__main__':- print("""- STOP! If you're just trying to download files, check the README.md file for instructions.- If you're developing this project, use start.py instead.- """)+ print("""STOP! If you're just trying to download files, check the README.md file for instructions.+ If you're developing this project, use start.py instead.""")exit()diff --git a/cyberdrop_dl/scraper/scraper.py b/cyberdrop_dl/scraper/scraper.pyindex a76476b71..bb13b91ed 100644--- a/cyberdrop_dl/scraper/scraper.py+++ b/cyberdrop_dl/scraper/scraper.py@@ -1,4 +1,5 @@import asyncio+from typing import Dictfrom .scraper_helper import ScrapeMapperfrom ..base_functions.base_functions import log@@ -6,16 +7,15 @@ from ..base_functions.data_classes import AuthData, SkipDatafrom ..client.client import Client-async def scrape(urls, client: Client, include_id: bool, jdownloader_enable: bool, jdownloader_device: str, xbunker_auth: AuthData,- socialmediagirls_auth: AuthData, simpcity_auth: AuthData, jdownloader_auth: AuthData,- separate_posts: bool, skip_data: SkipData, output_last: list):+async def scrape(urls, client: Client, file_args: Dict, jdownloader_args: Dict, runtime_args: Dict,+ jdownloader_auth: AuthData, simpcity_auth: AuthData, socialmediagirls_auth: AuthData,+ xbunker_auth: AuthData, skip_data: SkipData):await log("Starting Scrape")- scraper = ScrapeMapper(client=client, include_id=include_id, jdownloader_enable=jdownloader_enable,- jdownloader_device=jdownloader_device, xbunker_auth=xbunker_auth,+ scraper = ScrapeMapper(client=client, file_args=file_args, jdownloader_args=jdownloader_args,+ runtime_args=runtime_args, xbunker_auth=xbunker_auth,socialmediagirls_auth=socialmediagirls_auth, simpcity_auth=simpcity_auth,- jdownloader_auth=jdownloader_auth, separate_posts=separate_posts, skip_data=skip_data,- output_last=output_last)+ jdownloader_auth=jdownloader_auth, skip_data=skip_data)tasks = []for link in urls:tasks.append(scraper.map_url(link))diff --git a/cyberdrop_dl/scraper/scraper_helper.py b/cyberdrop_dl/scraper/scraper_helper.pyindex 07bc88f24..62d18909c 100644--- a/cyberdrop_dl/scraper/scraper_helper.py+++ b/cyberdrop_dl/scraper/scraper_helper.py@@ -1,4 +1,5 @@import asyncio+from typing import Dictimport aiofilesfrom myjdapi import myjdapi@@ -27,19 +28,19 @@ from ..crawlers.SimpCity_Spider import SimpCityCrawlerfrom ..crawlers.XBunker_Spider import XBunkerCrawlerfrom ..crawlers.XBunkr_Spider import XBunkrCrawlerfrom ..base_functions.base_functions import log-from ..base_functions.data_classes import CascadeItem, SkipData+from ..base_functions.data_classes import CascadeItem, SkipData, AuthDatafrom ..client.rate_limiting import AsyncRateLimiter-class ScrapeMapper():- def __init__(self, *, include_id=False, jdownloader_enable=False, jdownloader_device=None, xbunker_auth=None,- socialmediagirls_auth=None, simpcity_auth=None, jdownloader_auth=None, separate_posts=False,- skip_data: SkipData, client: Client, output_last: list):- self.include_id = include_id- self.jdownloader_enable = jdownloader_enable- self.jdownloader_device = jdownloader_device- self.separate_posts = separate_posts- self.output_last = output_last+class ScrapeMapper:+ def __init__(self, *, client: Client, file_args: Dict, jdownloader_args: Dict, runtime_args: Dict,+ jdownloader_auth: AuthData, simpcity_auth: AuthData, socialmediagirls_auth: AuthData,+ xbunker_auth: AuthData, skip_data: SkipData):+ self.include_id = runtime_args['include_id']+ self.jdownloader_enable = jdownloader_args['jdownloader_enable']+ self.jdownloader_device = jdownloader_args['jdownloader_device']+ self.separate_posts = runtime_args['separate_posts']+ self.output_last = [runtime_args['output_last_forum_post'], file_args['output_last_forum_post_file']]self.xbunker_auth = xbunker_authself.socialmediagirls_auth = socialmediagirls_authself.simpcity_auth = simpcity_auth@@ -76,11 +77,11 @@ class ScrapeMapper():self.forum_limiter = asyncio.Semaphore(4)self.semaphore = asyncio.Semaphore(1)self.mapping = {"anonfiles.com": self.Anonfiles, "bayfiles": self.Anonfiles, "xbunkr": self.XBunkr,- "bunkr": self.Bunkr, "coomer.party": self.coomer, "cyberdrop": self.Cyberdrop,- "cyberfile.is": self.cyberfile, "erome.com": self.Erome, "gfycat.com": self.gfycat,+ "bunkr": self.Bunkr, "coomer.party": self.Coomer, "cyberdrop": self.Cyberdrop,+ "cyberfile.is": self.Cyberfile, "erome.com": self.Erome, "gfycat.com": self.Gfycat,"gofile.io": self.GoFile, "img.kiwi": self.ShareX, "jpg.church": self.ShareX,"kemono.party": self.Kemono, "pixeldrain.com": self.Pixeldrain, "pixl.is": self.ShareX,- "postimg": self.Postimg, "redgifs.com": self.redgifs, "rule34.xxx": self.Rule34,+ "postimg": self.Postimg, "redgifs.com": self.Redgifs, "rule34.xxx": self.Rule34,"saint.to": self.Saint, "socialmediagirls": self.SocialMediaGirls,"simpcity": self.SimpCity, "xbunker": self.XBunker}@@ -115,7 +116,7 @@ class ScrapeMapper():await self.Cascade.add_albums(domain_obj)await cyberdrop_session.exit_handler()- async def coomer(self, url: URL, title=None):+ async def Coomer(self, url: URL, title=None):coomer_session = Session(self.client)if not self.coomer_crawler:self.coomer_crawler = CoomerCrawler(include_id=self.include_id)@@ -125,7 +126,7 @@ class ScrapeMapper():await self.Cascade.add_albums(domain_obj)await coomer_session.exit_handler()- async def cyberfile(self, url: URL, title=None):+ async def Cyberfile(self, url: URL, title=None):cyberfile_session = Session(self.client)if not self.cyberfile_crawler:self.cyberfile_crawler = CyberfileCrawler()@@ -151,7 +152,7 @@ class ScrapeMapper():if not self.gofile_crawler:try:self.gofile_crawler = GofileCrawler()- except:+ except SystemExit:await log("Couldn't start the GoFile crawler")returndomain_obj = await self.gofile_crawler.fetch(gofile_session, url)@@ -170,7 +171,7 @@ class ScrapeMapper():await self.Cascade.add_albums(domain_obj)await kemono_session.exit_handler()- async def gfycat(self, url: URL, title=None):+ async def Gfycat(self, url: URL, title=None):gfycat_session = Session(self.client)if not self.gfycat_crawler:self.gfycat_crawler = GfycatCrawler()@@ -202,7 +203,7 @@ class ScrapeMapper():await self.Cascade.add_albums(domain_obj)await postimg_session.exit_handler()- async def redgifs(self, url: URL, title=None):+ async def Redgifs(self, url: URL, title=None):redgifs_session = Session(self.client)if not self.redgifs_crawler:self.redgifs_crawler = RedGifsCrawler()