Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Remove lock and flatten code a little
Arkadiy Illarionovf43af945249c
diff --git a/cyberdrop_dl/client/client.py b/cyberdrop_dl/client/client.pyindex bcafaeb2d..56dc89b78 100644--- a/cyberdrop_dl/client/client.py+++ b/cyberdrop_dl/client/client.py@@ -18,7 +18,7 @@ import certififrom cyberdrop_dl.downloader.progress_definitions import file_progressfrom .rate_limiting import AsyncRateLimiter, throttlefrom ..base_functions.base_functions import logger-from ..base_functions.data_classes import FileLock, MediaItem+from ..base_functions.data_classes import MediaItemfrom ..base_functions.error_classes import DownloadFailure, InvalidContentTypeFailure@@ -95,13 +95,13 @@ class ScrapeSession:async def get_no_resp(self, url: URL, headers: dict):async with self.client.simultaneous_session_limit:async with self.rate_limiter:- async with self.client_session.get(url, headers=headers, ssl=self.client.ssl_context) as response:+ async with self.client_session.get(url, headers=headers, ssl=self.client.ssl_context):passasync def post_data_no_resp(self, url: URL, data: dict):async with self.client.simultaneous_session_limit:async with self.rate_limiter:- async with self.client_session.post(url, data=data, headers=self.headers, ssl=self.client.ssl_context) as response:+ async with self.client_session.post(url, data=data, headers=self.headers, ssl=self.client.ssl_context):passasync def exit_handler(self):diff --git a/cyberdrop_dl/crawlers/Xenforo_Spider.py b/cyberdrop_dl/crawlers/Xenforo_Spider.pyindex d681a5a71..7921dddb1 100644--- a/cyberdrop_dl/crawlers/Xenforo_Spider.py+++ b/cyberdrop_dl/crawlers/Xenforo_Spider.py@@ -22,37 +22,37 @@ class ForumLogin:async def login(self, session: ScrapeSession, url: URL, quiet: bool):"""Handles forum logging in"""- if self.username and self.password:- if self.logged_in:- return- self.lock = True- domain = URL("https://" + url.host) / "login"- text = await session.get_text(domain)- await asyncio.sleep(5)- soup = BeautifulSoup(text, 'html.parser')-- inputs = soup.select('form input')- data = {- elem['name']: elem['value']- for elem in inputs- if elem.get('name') and elem.get('value')- }- data.update({"login": self.username, "password": self.password,- "_xfRedirect": str(URL("https://" + url.host))})- await session.post_data_no_resp(domain / "login", data=data)- await asyncio.sleep(5)- text = await session.get_text(domain)- if "You are already logged in" in text:- self.logged_in = True- self.lock = False- return- else:- self.lock = False- raise FailedLoginFailure()- else:+ if not self.username or not self.password:await log(f"[red]Login wasn't provided for {self.name}[/red]", quiet=quiet)raise FailedLoginFailure()+ if self.logged_in:+ return++ domain = URL("https://" + url.host) / "login"+ text = await session.get_text(domain)+ await asyncio.sleep(5)+ soup = BeautifulSoup(text, 'html.parser')++ inputs = soup.select('form input')+ data = {+ elem['name']: elem['value']+ for elem in inputs+ if elem.get('name') and elem.get('value')+ }+ data.update({+ "login": self.username,+ "password": self.password,+ "_xfRedirect": str(URL("https://" + url.host))+ })+ await session.post_data_no_resp(domain / "login", data=data)+ await asyncio.sleep(5)+ text = await session.get_text(domain)+ if "You are already logged in" not in text:+ raise FailedLoginFailure()++ self.logged_in = True+class XenforoCrawler:def __init__(self, *, scraping_mapper, args: dict, SQL_Helper: SQLHelper, quiet: bool):