Skip to content

Bulk asynchronous downloader for multiple file hosts

Clean imports, add comments

Jules-WinnfieldXf62600037d87
diff --git a/cyberdrop_dl/clients/scraper_client.py b/cyberdrop_dl/clients/scraper_client.py
index 2142a5185..9be52204c 100644
--- a/cyberdrop_dl/clients/scraper_client.py
+++ b/cyberdrop_dl/clients/scraper_client.py
@@ -83,6 +83,7 @@ class ScraperClient:
@limiter
async def get_text(self, domain: str, url: URL, client_session: ClientSession) -> str:
+ """Returns a text object from the given URL"""
async with client_session.get(url, headers=self._headers, ssl=self.client_manager.ssl_context,
proxy=self.client_manager.proxy) as response:
await self.client_manager.check_http_status(response.status, response.headers, response.url)
@@ -90,6 +91,7 @@ class ScraperClient:
@limiter
async def post_data(self, domain: str, url: URL, client_session: ClientSession, data: Dict) -> Dict:
+ """Returns a JSON object from the given URL when posting data"""
async with client_session.post(url, headers=self._headers, ssl=self.client_manager.ssl_context,
proxy=self.client_manager.proxy, data=data) as response:
await self.client_manager.check_http_status(response.status, response.headers, response.url)
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.py
index cef922b01..3fbb67d5c 100644
--- a/cyberdrop_dl/main.py
+++ b/cyberdrop_dl/main.py
@@ -5,7 +5,6 @@ import os
import sys
import aiorun
-from rich import console
from rich.live import Live
from cyberdrop_dl.managers.manager import Manager
diff --git a/cyberdrop_dl/managers/args_manager.py b/cyberdrop_dl/managers/args_manager.py
index 6cdd89133..e2f35af86 100644
--- a/cyberdrop_dl/managers/args_manager.py
+++ b/cyberdrop_dl/managers/args_manager.py
@@ -15,6 +15,7 @@ class ArgsManager:
self.other_links: list = []
def startup(self) -> None:
+ """Parses arguments and sets variables accordingly"""
self.parsed_args = parse_args().__dict__
self.immediate_download = self.parsed_args['download']
diff --git a/cyberdrop_dl/managers/download_manager.py b/cyberdrop_dl/managers/download_manager.py
index 758b4a8d7..b1f03ec9e 100644
--- a/cyberdrop_dl/managers/download_manager.py
+++ b/cyberdrop_dl/managers/download_manager.py
@@ -39,6 +39,7 @@ class DownloadManager:
task.cancel()
async def get_download_limit(self, key: str) -> int:
+ """Returns the download limit for a domain"""
if key in self.download_limits:
instances = self.download_limits[key]
else:
diff --git a/cyberdrop_dl/managers/progress_manager.py b/cyberdrop_dl/managers/progress_manager.py
index e6664e156..6bc979ce5 100644
--- a/cyberdrop_dl/managers/progress_manager.py
+++ b/cyberdrop_dl/managers/progress_manager.py
@@ -1,5 +1,4 @@
from dataclasses import field
-from typing import Dict
from rich.layout import Layout
diff --git a/cyberdrop_dl/ui/prompts/settings_global_prompts.py b/cyberdrop_dl/ui/prompts/settings_global_prompts.py
index 69e308b2e..5f83ad0a0 100644
--- a/cyberdrop_dl/ui/prompts/settings_global_prompts.py
+++ b/cyberdrop_dl/ui/prompts/settings_global_prompts.py
@@ -15,8 +15,6 @@ console = Console()
def edit_global_settings_prompt(manager: Manager) -> None:
"""Edit the authentication values"""
- auth = manager.config_manager.authentication_data
-
while True:
console.clear()
console.print("Editing Global Settings")
diff --git a/cyberdrop_dl/ui/prompts/url_file_prompts.py b/cyberdrop_dl/ui/prompts/url_file_prompts.py
index af89097f1..0434c9514 100644
--- a/cyberdrop_dl/ui/prompts/url_file_prompts.py
+++ b/cyberdrop_dl/ui/prompts/url_file_prompts.py
@@ -2,7 +2,6 @@ import re
from pathlib import Path
from InquirerPy import inquirer
-from InquirerPy.base.control import Choice
from rich.console import Console
console = Console()
diff --git a/cyberdrop_dl/utils/sorting.py b/cyberdrop_dl/utils/sorting.py
index 06e7564af..5626ae04c 100644
--- a/cyberdrop_dl/utils/sorting.py
+++ b/cyberdrop_dl/utils/sorting.py
@@ -17,6 +17,7 @@ class Sorter:
self.other_dir = other_dir
async def find_files_in_dir(self, directory: Path) -> list:
+ """Finds all files in a directory and returns them in a list"""
file_list = []
for x in directory.iterdir():
if x.is_file():
@@ -26,6 +27,7 @@ class Sorter:
return file_list
async def sort(self) -> None:
+ """Sorts the files in the download directory into their respective folders"""
audio_count = 0
image_count = 0
video_count = 0
@@ -70,6 +72,7 @@ class Sorter:
await log_with_color(f"Organized: {other_count} Other Files", style="green")
async def move_cd(self, file: Path, dest: Path) -> None:
+ """Moves a file to a destination folder"""
try:
dest_file = dest / file.name
file.rename(dest_file)
diff --git a/cyberdrop_dl/utils/utilities.py b/cyberdrop_dl/utils/utilities.py
index 4f1d65959..a379b171b 100644
--- a/cyberdrop_dl/utils/utilities.py
+++ b/cyberdrop_dl/utils/utilities.py
@@ -166,6 +166,7 @@ async def purge_dir(dirname: Path) -> None:
async def check_partials_and_empty_folders(manager: Manager):
+ """Checks for partial downloads and empty folders"""
if manager.config_manager.settings_data['Runtime_Options']['delete_partial_files']:
await log_with_color("Deleting partial downloads...", "bold_red")
partial_downloads = manager.directory_manager.downloads.rglob("*.part")