Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
move download_spacer to somewhere accessible
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules-WinnfieldX committed Dec 18, 2023
1 parent ce4a741 commit 55e5e9d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cyberdrop_dl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.1.7"
__version__ = "5.1.8"
2 changes: 1 addition & 1 deletion cyberdrop_dl/clients/download_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def limiter(func):
@wraps(func)
async def wrapper(self, *args, **kwargs):
domain_limiter = await self.client_manager.get_rate_limiter(args[0])
await asyncio.sleep(await self.get_downloader_spacer(args[0]))
await asyncio.sleep(await self.client_manager.get_downloader_spacer(args[0]))
await self._global_limiter.acquire()
await domain_limiter.acquire()

Expand Down
9 changes: 9 additions & 0 deletions cyberdrop_dl/managers/client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def __init__(self, manager: Manager):
"pixeldrain": AsyncLimiter(10, 1),
"other": AsyncLimiter(25, 1)
}
self.download_spacer = {'bunkr': 0.5, 'bunkrr': 0.5, 'cyberdrop': 0, 'coomer': 0, 'cyberfile': 0, 'kemono': 0,
"pixeldrain": 0}

self.global_rate_limiter = AsyncLimiter(self.rate_limit, 1)
self.session_limit = asyncio.Semaphore(50)
self.download_session_limit = asyncio.Semaphore(self.manager.config_manager.global_settings_data['Rate_Limiting_Options']['max_simultaneous_downloads'])
Expand All @@ -54,6 +57,12 @@ def __init__(self, manager: Manager):

"""~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""

async def get_downloader_spacer(self, key: str) -> float:
"""Returns the download spacer for a domain"""
if key in self.download_spacer:
return self.download_spacer[key]
return 0.1

async def get_rate_limiter(self, domain: str) -> AsyncLimiter:
"""Get a rate limiter for a domain"""
if domain in self.domain_rate_limits:
Expand Down
7 changes: 0 additions & 7 deletions cyberdrop_dl/managers/download_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ def __init__(self, manager: Manager):
self.file_lock = FileLock()

self.download_limits = {'bunkr': 1, 'bunkrr': 1, 'cyberdrop': 1, 'coomer': 2, 'cyberfile': 2, 'kemono': 2, "pixeldrain": 2}
self.download_spacer = {'bunkr': 0.5, 'bunkrr': 0.5, 'cyberdrop': 0, 'coomer': 0, 'cyberfile': 0, 'kemono': 0, "pixeldrain": 0}

async def get_downloader_spacer(self, key: str) -> float:
"""Returns the download spacer for a domain"""
if key in self.download_spacer:
return self.download_spacer[key]
return 0.1

async def get_download_limit(self, key: str) -> int:
"""Returns the download limit for a domain"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cyberdrop-dl"
version = "5.1.7"
version = "5.1.8"
description = "Bulk downloader for multiple file hosts"
authors = ["Jules Winnfield <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 55e5e9d

Please sign in to comment.