Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
allow iter chunks by enabling one packet over limit to be processed
datawhores61fe2737bb90
diff --git a/.vscode/launch.json b/.vscode/launch.jsonindex b1fa522a6..be007e1a0 100644--- a/.vscode/launch.json+++ b/.vscode/launch.json@@ -15,5 +15,27 @@"python":"/home/john/src/CyberDropDownloader/.venv/bin/python3.11",},++ {+ "name": "simpcity",+ "type": "python",+ "request": "launch",+ "program": "/home/john/src/CyberDropDownloader/.venv/bin/cyberdrop-dl",+ "args": ["--ignore-history","--download","https://simpcity.su/threads/twintwitcherz-jessicatalystic-low_ad_988-linneas_life_-linneas_feet.8265/page-6"],+ "console": "integratedTerminal",+ "justMyCode": false,+ "python":"/home/john/src/CyberDropDownloader/.venv/bin/python3.11",+ },++ {+ "name": "simpcity shadow",+ "type": "python",+ "request": "launch",+ "program": "/home/john/src/CyberDropDownloader/.venv/bin/cyberdrop-dl",+ "args": ["--ignore-history","--download","https://simpcity.su/threads/shadowifey.100509"],+ "console": "integratedTerminal",+ "justMyCode": false,+ "python":"/home/john/src/CyberDropDownloader/.venv/bin/python3.11",+ },]}\ No newline at end of filediff --git a/cyberdrop_dl/clients/download_client.py b/cyberdrop_dl/clients/download_client.pyindex 36fe7bab5..94df891c0 100644--- a/cyberdrop_dl/clients/download_client.py+++ b/cyberdrop_dl/clients/download_client.py@@ -142,7 +142,7 @@ class DownloadClient:if not media_item.partial_file.is_file():media_item.partial_file.touch()async with aiofiles.open(media_item.partial_file, mode='ab') as f:- async for chunk in content.iter_chunked(1024):+ async for chunk,_ in content.iter_chunks():await self.client_manager.check_bucket(chunk)await asyncio.sleep(0)await f.write(chunk)diff --git a/cyberdrop_dl/managers/leaky.py b/cyberdrop_dl/managers/leaky.pyindex 2b072e71e..1d049fe10 100644--- a/cyberdrop_dl/managers/leaky.py+++ b/cyberdrop_dl/managers/leaky.py@@ -3,6 +3,7 @@ from aiolimiter import AsyncLimiterclass LeakyBucket( AsyncLimiter):def __init__(self,manager):self.download_speed_limit = manager.config_manager.global_settings_data['Rate_Limiting_Options']['download_speed_limit']+ self.max_amount=1024*1024*10super().__init__(self.download_speed_limit*1024,1)async def acquire(self, amount: float = 1):if self.download_speed_limit<=0:@@ -10,3 +11,23 @@ class LeakyBucket( AsyncLimiter):if not isinstance(amount, int):amount=len(amount)await super().acquire(amount)+ def has_capacity(self, amount: float = 1) -> bool:+ """Check if there is enough capacity remaining in the limiter++ :param amount: How much capacity you need to be available.++ """+ self._leak()+ requested = self._level + amount+ # if there are tasks waiting for capacity, signal to the first+ # there there may be some now (they won't wake up until this task+ # yields with an await)+ if requested < self.max_rate:+ for fut in self._waiters.values():+ if not fut.done():+ fut.set_result(True)+ break+ #allows for one packet to be received until bucket empties+ if self._level>self.max_rate:+ return False+ return self._level + amount <= self.max_amountdiff --git a/cyberdrop_dl/scraper/crawlers/simpcity_crawler.py b/cyberdrop_dl/scraper/crawlers/simpcity_crawler.pyindex fe0cc5d11..350656021 100644--- a/cyberdrop_dl/scraper/crawlers/simpcity_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/simpcity_crawler.py@@ -103,7 +103,10 @@ class SimpCityCrawler(Crawler):scrape_post, continue_scraping = await self.check_post_number(post_number, current_post_number)if scrape_post:- date = int(post.select_one(self.post_date_selector).get(self.post_date_attribute))+ try:+ date = int(post.select_one(self.post_date_selector).get(self.post_date_attribute))+ except:+ passnew_scrape_item = await self.create_scrape_item(scrape_item, thread_url, title, False, None, date)# for elem in post.find_all(self.quotes_selector):