Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Make the read timeout user adjustable.
Jules-WinnfieldX31c85248aaf3
diff --git a/cyberdrop_dl/base_functions/config_schema.py b/cyberdrop_dl/base_functions/config_schema.pyindex 1f66eb765..3b93f13d4 100644--- a/cyberdrop_dl/base_functions/config_schema.py+++ b/cyberdrop_dl/base_functions/config_schema.py@@ -19,7 +19,7 @@ config_default: Dict = {"xbunker_password": "",},"Files": {- "variable_cache_file": "cache.yaml",+ "variable_cache_file": "internal_variable_cache.yaml","db_file": "download_history.sqlite","errored_download_urls_file": "Errored_Download_URLs.csv","errored_scrape_urls_file": "Errored_Scrape_URLs.csv",@@ -66,6 +66,7 @@ config_default: Dict = {},"Ratelimiting": {"connection_timeout": 15,+ "read_timeout": 300,"ratelimit": 50,"throttle": 0.5,},diff --git a/cyberdrop_dl/client/client.py b/cyberdrop_dl/client/client.pyindex bc329280c..e969d13c7 100644--- a/cyberdrop_dl/client/client.py+++ b/cyberdrop_dl/client/client.py@@ -44,8 +44,10 @@ def scrape_limit(func):class Client:"""Creates a 'client' that can be referenced by scraping or download sessions"""- def __init__(self, ratelimit: int, throttle: float, secure: bool, connect_timeout: int, user_agent: str):+ def __init__(self, ratelimit: int, throttle: float, secure: bool, connect_timeout: int, read_timeout: int,+ user_agent: str):self.connect_timeout = connect_timeout+ self.read_timeout = read_timeoutself.ratelimit = ratelimitself.throttle = throttleself.simultaneous_session_limit = asyncio.Semaphore(50)@@ -120,8 +122,8 @@ class DownloadSession:def __init__(self, client: Client):self.client = clientself.headers = {"user-agent": client.user_agent}- self.timeouts = aiohttp.ClientTimeout(total=300 + self.client.connect_timeout,- connect=self.client.connect_timeout, sock_read=300)+ self.timeouts = aiohttp.ClientTimeout(total=self.client.read_timeout + self.client.connect_timeout,+ connect=self.client.connect_timeout, sock_read=self.client.read_timeout)self.client_session = aiohttp.ClientSession(headers=self.headers, raise_for_status=True,cookie_jar=self.client.cookies, timeout=self.timeouts)self.throttle_times: Dict[str, float] = {}diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.pyindex 70ec01848..232d49616 100644--- a/cyberdrop_dl/main.py+++ b/cyberdrop_dl/main.py@@ -46,7 +46,7 @@ def parse_args() -> argparse.Namespace:path_opts.add_argument("-o", "--output-folder", type=Path, help="folder to download files to (default: %(default)s)", default=config_group["output_folder"])path_opts.add_argument("--config-file", type=Path, help="config file to read arguments from (default: %(default)s)", default="config.yaml")- path_opts.add_argument("--variable-cache-file", type=Path, help="variable cache file to read from and write to (default: %(default)s)", default=config_group["variable_cache_file"])+ path_opts.add_argument("--variable-cache-file", type=Path, help="internal variable cache file to read from and write to (default: %(default)s)", default=config_group["variable_cache_file"])path_opts.add_argument("--db-file", type=Path, help="history database file to write to (default: %(default)s)", default=config_group["db_file"])path_opts.add_argument("--errored-download-urls-file", type=Path, default=config_group["errored_download_urls_file"], help="csv file to write failed download information to (default: %(default)s)")path_opts.add_argument("--errored-scrape-urls-file", type=Path, default=config_group["errored_scrape_urls_file"], help="csv file to write failed scrape information to (default: %(default)s)")@@ -106,6 +106,7 @@ def parse_args() -> argparse.Namespace:config_group = config_data["Ratelimiting"]ratelimit_opts = parser.add_argument_group("Ratelimiting options")ratelimit_opts.add_argument("--connection-timeout", type=int, default=config_group["connection_timeout"], help="number of seconds to wait attempting to connect to a URL during the downloading phase (default: %(default)s)")+ ratelimit_opts.add_argument("--read-timeout", type=int, default=config_group["read_timeout"], help="number of seconds to wait attempting to read all file data during the downloading phase (default: %(default)s)")ratelimit_opts.add_argument("--ratelimit", type=int, default=config_group["ratelimit"], help="this applies to requests made in the program during scraping, the number you provide is in requests/seconds (default: %(default)s)")ratelimit_opts.add_argument("--throttle", type=int, default=config_group["throttle"], help="this is a throttle between requests during the downloading phase, the number is in seconds (default: %(default)s)")@@ -281,7 +282,7 @@ 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']['user_agent'])+ args["Ratelimiting"]["read_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, error_writer, cache_manager)