Skip to content

Bulk asynchronous downloader for multiple file hosts

Add capability to specify user-agent in config (#422)

Arkadiy Illarionove4d68d71e1ef
diff --git a/cyberdrop_dl/base_functions/config_schema.py b/cyberdrop_dl/base_functions/config_schema.py
index 8db68633c..dc9ae98f2 100644
--- a/cyberdrop_dl/base_functions/config_schema.py
+++ b/cyberdrop_dl/base_functions/config_schema.py
@@ -61,13 +61,14 @@ config_default = {
"block_sub_folders": False,
"disable_attempt_limit": False,
"include_id": False,
- "skip_download_mark_completed": False,
"output_errored_urls": False,
"output_unsupported_urls": False,
"proxy": "",
"remove_bunkr_identifier": False,
"required_free_space": 5,
"simultaneous_downloads_per_domain": 4,
+ "skip_download_mark_completed": False,
+ "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/112.0",
},
"Sorting": {
"sort_downloads": False,
diff --git a/cyberdrop_dl/client/client.py b/cyberdrop_dl/client/client.py
index bf3481f20..0c1d5db0f 100644
--- a/cyberdrop_dl/client/client.py
+++ b/cyberdrop_dl/client/client.py
@@ -41,12 +41,12 @@ def scrape_limit(func):
class Client:
"""Creates a 'client' that can be referenced by scraping or download sessions"""
- def __init__(self, ratelimit: int, throttle: int, secure: bool, connect_timeout: int):
+ def __init__(self, ratelimit: int, throttle: int, secure: bool, connect_timeout: int, user_agent: str):
self.connect_timeout = connect_timeout
self.ratelimit = ratelimit
self.throttle = throttle
self.simultaneous_session_limit = asyncio.Semaphore(50)
- self.user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/112.0'
+ self.user_agent = user_agent
self.verify_ssl = secure
self.ssl_context = ssl.create_default_context(cafile=certifi.where()) if secure else False
self.cookies = aiohttp.CookieJar(quote_cookie=False)
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.py
index cb5405dfe..faa487157 100644
--- a/cyberdrop_dl/main.py
+++ b/cyberdrop_dl/main.py
@@ -229,7 +229,8 @@ async def director(args: dict, links: list) -> None:
links = await consolidate_links(args, links)
client = Client(args['Ratelimiting']['ratelimit'], args['Ratelimiting']['throttle'],
- args['Runtime']['allow_insecure_connections'], args["Ratelimiting"]["connection_timeout"])
+ args['Runtime']['allow_insecure_connections'], args["Ratelimiting"]["connection_timeout"],
+ args['Runtime']['user_agent'])
SQL_Helper = SQLHelper(args['Ignore']['ignore_history'], args['Ignore']['ignore_cache'], args['Files']['db_file'])
Scraper = ScrapeMapper(args, client, SQL_Helper, False)