Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
refactor: references
NTFSvolumecaff3494431b
diff --git a/cyberdrop_dl/clients/download_client.py b/cyberdrop_dl/clients/download_client.pyindex f8b6be0e6..c8303c217 100644--- a/cyberdrop_dl/clients/download_client.py+++ b/cyberdrop_dl/clients/download_client.py@@ -13,7 +13,8 @@ import aiohttpfrom aiohttp import ClientSessionfrom cyberdrop_dl.clients.errors import DownloadError, InvalidContentTypeError-from cyberdrop_dl.utils.utilities import DEBUG_VAR, FILE_FORMATS, log+from cyberdrop_dl.utils.constants import DEBUG_VAR, FILE_FORMATS+from cyberdrop_dl.utils.logger import logif TYPE_CHECKING:from typing import Any, Callable, Coroutinediff --git a/cyberdrop_dl/clients/hash_client.py b/cyberdrop_dl/clients/hash_client.pyindex a6f96529e..d0db33b45 100644--- a/cyberdrop_dl/clients/hash_client.py+++ b/cyberdrop_dl/clients/hash_client.py@@ -10,7 +10,7 @@ from typing import TYPE_CHECKING, AsyncGeneratorfrom send2trash import send2trashfrom cyberdrop_dl.ui.prompts.continue_prompt import enter_to_continue-from cyberdrop_dl.utils.utilities import log+from cyberdrop_dl.utils.logger import logif TYPE_CHECKING:from yarl import URLdiff --git a/cyberdrop_dl/clients/scraper_client.py b/cyberdrop_dl/clients/scraper_client.pyindex c6cba4314..2f46200c2 100644--- a/cyberdrop_dl/clients/scraper_client.py+++ b/cyberdrop_dl/clients/scraper_client.py@@ -10,7 +10,8 @@ from bs4 import BeautifulSoupfrom yarl import URLfrom cyberdrop_dl.clients.errors import DDOSGuardError, InvalidContentTypeError-from cyberdrop_dl.utils.utilities import DEBUG_VAR, log+from cyberdrop_dl.utils.constants import DEBUG_VAR+from cyberdrop_dl.utils.logger import logif TYPE_CHECKING:from multidict import CIMultiDictProxydiff --git a/cyberdrop_dl/downloader/downloader.py b/cyberdrop_dl/downloader/downloader.pyindex 8fe2282aa..ceb4fde4c 100644--- a/cyberdrop_dl/downloader/downloader.py+++ b/cyberdrop_dl/downloader/downloader.py@@ -14,7 +14,8 @@ from filedate import Filefrom cyberdrop_dl.clients.download_client import is_4xx_client_errorfrom cyberdrop_dl.clients.errors import CDLBaseError, DownloadError, InsufficientFreeSpaceError, RestrictedFiletypeErrorfrom cyberdrop_dl.managers.real_debrid.errors import RealDebridError-from cyberdrop_dl.utils.utilities import CustomHTTPStatus, log+from cyberdrop_dl.utils.constants import CustomHTTPStatus+from cyberdrop_dl.utils.logger import logif TYPE_CHECKING:from cyberdrop_dl.clients.download_client import DownloadClientdiff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.pyindex af6355e17..efaeac8cc 100644--- a/cyberdrop_dl/main.py+++ b/cyberdrop_dl/main.py@@ -5,42 +5,30 @@ import contextlibimport loggingimport osimport sys-import timefrom pathlib import Path+from time import perf_counterfrom rich.console import Consolefrom rich.logging import RichHandlerfrom cyberdrop_dl.clients.errors import InvalidYamlError-from cyberdrop_dl.managers.console_manager import print_from cyberdrop_dl.managers.manager import Managerfrom cyberdrop_dl.scraper.scraper import ScrapeMapperfrom cyberdrop_dl.ui.ui import program_ui+from cyberdrop_dl.utils.logger import (+ log,+ log_spacer,+ log_with_color,+ print_to_console,+)from cyberdrop_dl.utils.sorting import Sorterfrom cyberdrop_dl.utils.utilities import (- DEFAULT_CONSOLE_WIDTH,check_latest_pypi,check_partials_and_empty_folders,- log,- log_spacer,- log_with_color,send_webhook_message,sent_apprise_notifications,)-RICH_HANDLER_CONFIG = {"show_time": True, "rich_tracebacks": True, "tracebacks_show_locals": False}--RICH_HANDLER_DEBUG_CONFIG = {- "show_time": True,- "rich_tracebacks": True,- "tracebacks_show_locals": True,- "locals_max_string": DEFAULT_CONSOLE_WIDTH,- "tracebacks_extra_lines": 2,- "locals_max_length": 20,-}--start_time = 0-def startup() -> Manager:"""Starts the program and returns the manager.@@ -48,26 +36,21 @@ def startup() -> Manager:This will also run the UI for the programAfter this function returns, the manager will be ready to use and scraping / downloading can begin."""- try:- manager = Manager()- manager.startup()-- if not manager.args_manager.immediate_download:- program_ui(manager)- return manager+ manager = Manager()+ manager.startup()- except InvalidYamlError as e:- print_(e.message_rich)- sys.exit(1)+ if not manager.args_manager.immediate_download:+ program_ui(manager)- except KeyboardInterrupt:- print_("\nExiting...")- sys.exit(0)+ return managerasync def runtime(manager: Manager) -> None:"""Main runtime loop for the program, this will run until all scraping and downloading is complete."""+ if manager.args_manager.sort_all_configs:+ return+scrape_mapper = ScrapeMapper(manager)async with asyncio.TaskGroup() as task_group:@@ -79,7 +62,7 @@ async def post_runtime(manager: Manager) -> None:"""Actions to complete after main runtime, and before ui shutdown."""log_spacer(20)log_with_color(- f"Running Post-Download Processes For Config: {manager.config_manager.loaded_config}...\n",+ f"Running Post-Download Processes For Config: {manager.config_manager.loaded_config}","green",20,)@@ -94,6 +77,7 @@ async def post_runtime(manager: Manager) -> None:):sorter = Sorter(manager)await sorter.sort()+await check_partials_and_empty_folders(manager)if manager.config_manager.settings_data["Runtime_Options"]["update_last_forum_post"]:@@ -104,24 +88,24 @@ def setup_debug_logger(manager: Manager) -> Path | None:logger_debug = logging.getLogger("cyberdrop_dl_debug")debug_log_file_path = Nonerunning_in_IDE = os.getenv("PYCHARM_HOSTED") or os.getenv("TERM_PROGRAM") == "vscode"- import cyberdrop_dl.utils.utilities+ import cyberdrop_dl.utils.constants as contantsif running_in_IDE or manager.config_manager.settings_data["Runtime_Options"]["log_level"] == -1:manager.config_manager.settings_data["Runtime_Options"]["log_level"] = 10- cyberdrop_dl.utils.utilities.DEBUG_VAR = True+ contants.DEBUG_VAR = Trueif running_in_IDE or manager.config_manager.settings_data["Runtime_Options"]["console_log_level"] == -1:- cyberdrop_dl.utils.utilities.CONSOLE_DEBUG_VAR = True+ contants.CONSOLE_DEBUG_VAR = True- if cyberdrop_dl.utils.utilities.DEBUG_VAR:+ if contants.DEBUG_VAR:logger_debug.setLevel(manager.config_manager.settings_data["Runtime_Options"]["log_level"])debug_log_file_path = Path(__file__).parent / "cyberdrop_dl_debug.log"if running_in_IDE:debug_log_file_path = Path(__file__).parents[1] / "cyberdrop_dl_debug.log"rich_file_handler_debug = RichHandler(- **RICH_HANDLER_DEBUG_CONFIG,- console=Console(file=debug_log_file_path.open("w", encoding="utf8"), width=DEFAULT_CONSOLE_WIDTH),+ **contants.RICH_HANDLER_DEBUG_CONFIG,+ console=Console(file=debug_log_file_path.open("w", encoding="utf8"), width=contants.DEFAULT_CONSOLE_WIDTH),level=manager.config_manager.settings_data["Runtime_Options"]["log_level"],)@@ -133,9 +117,8 @@ def setup_debug_logger(manager: Manager) -> Path | None:return debug_log_file_path.resolve() if debug_log_file_path else None-async def switch_config_and_reset_logger(manager: Manager, config_name: str) -> None:- import cyberdrop_dl.managers.console_manager- import cyberdrop_dl.utils.utilities+def setup_logger(manager: Manager, config_name: str) -> None:+ import cyberdrop_dl.utils.constants as contantslogger = logging.getLogger("cyberdrop_dl")if manager.args_manager.all_configs:@@ -150,39 +133,37 @@ async def switch_config_and_reset_logger(manager: Manager, config_name: str) ->logger.setLevel(manager.config_manager.settings_data["Runtime_Options"]["log_level"])- if cyberdrop_dl.utils.utilities.DEBUG_VAR:+ if contants.DEBUG_VAR:manager.config_manager.settings_data["Runtime_Options"]["log_level"] = 10rich_file_handler = RichHandler(- **RICH_HANDLER_CONFIG,- console=Console(file=manager.path_manager.main_log.open("w", encoding="utf8"), width=DEFAULT_CONSOLE_WIDTH),+ **contants.RICH_HANDLER_CONFIG,+ console=Console(+ file=manager.path_manager.main_log.open("w", encoding="utf8"),+ width=contants.DEFAULT_CONSOLE_WIDTH,+ ),level=manager.config_manager.settings_data["Runtime_Options"]["log_level"],)logger.addHandler(rich_file_handler)-- cyberdrop_dl.managers.console_manager.LEVEL = manager.config_manager.settings_data["Runtime_Options"][- "console_log_level"- ]+ contants.CONSOLE_LEVEL = manager.config_manager.settings_data["Runtime_Options"]["console_log_level"]async def director(manager: Manager) -> None:"""Runs the program and handles the UI."""- global start_timemanager.path_manager.startup()manager.log_manager.startup()debug_log_file_path = setup_debug_logger(manager)- using_multiple_configs = Falseconfigs_to_run = [manager.config_manager.loaded_config]if manager.args_manager.all_configs:configs_to_run = manager.config_manager.get_configs()- using_multiple_configs = Trueconfigs_to_run.sort()- for current_config in configs_to_run:- if using_multiple_configs:- await switch_config_and_reset_logger(manager, current_config)+ start_time = manager.start_time+ while configs_to_run:+ current_config = configs_to_run[0]+ setup_logger(manager, current_config)configs_to_run.pop(0)log(f"Using Debug Log: {debug_log_file_path if debug_log_file_path else None}", 10)@@ -191,17 +172,13 @@ async def director(manager: Manager) -> None:log_spacer(20)log("Starting CDL...\n", 20)- if not manager.args_manager.sort_all_configs:- try:- async with manager.live_manager.get_main_live(stop=True):- await runtime(manager)- await post_runtime(manager)- except Exception:- log("\nAn error occurred, please report this to the developer:", 50, exc_info=True)- sys.exit(1)++ async with manager.live_manager.get_main_live(stop=True):+ await runtime(manager)+ await post_runtime(manager)log_spacer(20)- await manager.progress_manager.print_stats(start_time)+ manager.progress_manager.print_stats(start_time)if not configs_to_run:log_spacer(20)@@ -213,28 +190,36 @@ async def director(manager: Manager) -> None:log_with_color("Finished downloading. Enjoy :)", "green", 20, show_in_stats=False)await send_webhook_message(manager)- await sent_apprise_notifications(manager)- start_time = time.perf_counter()+ sent_apprise_notifications(manager)+ start_time = perf_counter()def main() -> None:- global start_time- start_time = time.perf_counter()- manager = startup()-loop = asyncio.new_event_loop()asyncio.set_event_loop(loop)+ exit_code = 1with contextlib.suppress(RuntimeError):try:+ manager = startup()asyncio.run(director(manager))-+ exit_code = 0+ except InvalidYamlError as e:+ print_to_console(e.message_rich)except KeyboardInterrupt:- print_("\nTrying to Exit...")with contextlib.suppress(Exception):+ print_to_console("\nTrying to Exit...")asyncio.run(manager.close())- sys.exit(1)+ except Exception:+ log_with_color(+ "An error occurred, please report this to the developer:",+ "bold red",+ 50,+ show_in_stats=False,+ exc_info=True,+ )+loop.close()- sys.exit(0)+ sys.exit(exit_code)if __name__ == "__main__":diff --git a/cyberdrop_dl/managers/args_manager.py b/cyberdrop_dl/managers/args_manager.pyindex d786fcdd6..94bf56349 100644--- a/cyberdrop_dl/managers/args_manager.py+++ b/cyberdrop_dl/managers/args_manager.py@@ -151,7 +151,7 @@ class ArgsManager:del self.parsed_args["retry_maintenance"]del self.parsed_args["input_file"]del self.parsed_args["output_folder"]- del self.parsed_args["appdata_folder"]+ del self.parsed_args["appdata_dir"]del self.parsed_args["config_file"]del self.parsed_args["log_folder"]del self.parsed_args["proxy"]diff --git a/cyberdrop_dl/managers/client_manager.py b/cyberdrop_dl/managers/client_manager.pyindex e8c7021b6..ed5084983 100644--- a/cyberdrop_dl/managers/client_manager.py+++ b/cyberdrop_dl/managers/client_manager.py@@ -15,7 +15,7 @@ from cyberdrop_dl.clients.download_client import DownloadClientfrom cyberdrop_dl.clients.errors import DDOSGuardError, DownloadError, ScrapeErrorfrom cyberdrop_dl.clients.scraper_client import ScraperClientfrom cyberdrop_dl.managers.leaky import LeakyBucket-from cyberdrop_dl.utils.utilities import CustomHTTPStatus+from cyberdrop_dl.utils.constants import CustomHTTPStatusif TYPE_CHECKING:from yarl import URLdiff --git a/cyberdrop_dl/managers/console_manager.py b/cyberdrop_dl/managers/console_manager.pyindex 34566eea7..e69de29bb 100644--- a/cyberdrop_dl/managers/console_manager.py+++ b/cyberdrop_dl/managers/console_manager.py@@ -1,77 +0,0 @@-from __future__ import annotations--import shutil-import time-from collections import deque-from typing import TYPE_CHECKING--from rich.console import Console--if TYPE_CHECKING:- from rich.text import Text---console = Console()-_HEIGHT, _ = 20, None-LEVEL = 100-QUEUE = deque()---def log(level: int, record: str, sleep: int = 0, *_, **__) -> None:- level = level or 10- if level >= LEVEL:- # QUEUE.append((record,sleep))- console.log(record)- if sleep:- time.sleep(sleep)---def print_(text: Text | str) -> None:- set_console_height()- console.print(text)---def set_console_height() -> None:- global _HEIGHT- _width, _new_height = shutil.get_terminal_size()- if _new_height != _HEIGHT:- _HEIGHT = _new_height- console.size = (_width, _HEIGHT - 4)---class ConsoleManager:- def __init__(self) -> None:- self.thread = None-- def startup(self) -> None:- pass- # self.thread = threading.Thread(target=self.flush_buffer_thread)- # self.thread.start()-- def close(self) -> None:- pass- # if self.thread:- # self.thread.join()-- @staticmethod- def flush_buffer_thread():- max_entries = 10- while True:- log_rends = []- try:- num = min(len(QUEUE), max_entries)- sleep = None- for _ in range(num):- log_renderable, sleep = QUEUE.popleft()- log_rends.append(log_renderable)- if sleep:- break- if not bool(log_rends):- time.sleep(0.3)- continue- set_console_height()- console.log("\n".join(log_rends))- if sleep:- time.sleep(sleep)- except Exception:- passdiff --git a/cyberdrop_dl/managers/download_manager.py b/cyberdrop_dl/managers/download_manager.pyindex e969faaae..727fddceb 100644--- a/cyberdrop_dl/managers/download_manager.py+++ b/cyberdrop_dl/managers/download_manager.py@@ -6,7 +6,8 @@ from base64 import b64encodefrom shutil import disk_usagefrom typing import TYPE_CHECKING-from cyberdrop_dl.utils.utilities import FILE_FORMATS, log_debug+from cyberdrop_dl.utils.constants import FILE_FORMATS+from cyberdrop_dl.utils.logger import log_debugif TYPE_CHECKING:from pathlib import Pathdiff --git a/cyberdrop_dl/managers/live_manager.py b/cyberdrop_dl/managers/live_manager.pyindex 3c005733e..1dfb68402 100644--- a/cyberdrop_dl/managers/live_manager.py+++ b/cyberdrop_dl/managers/live_manager.py@@ -6,8 +6,7 @@ from typing import TYPE_CHECKING, AsyncGeneratorfrom rich.console import Consolefrom rich.live import Live-from cyberdrop_dl.managers.console_manager import console-from cyberdrop_dl.utils.utilities import log+from cyberdrop_dl.utils.logger import console, logif TYPE_CHECKING:from rich.layout import Layoutdiff --git a/cyberdrop_dl/managers/log_manager.py b/cyberdrop_dl/managers/log_manager.pyindex e4139edbe..8ba389f75 100644--- a/cyberdrop_dl/managers/log_manager.py+++ b/cyberdrop_dl/managers/log_manager.py@@ -6,15 +6,14 @@ from typing import TYPE_CHECKINGimport aiofiles-from cyberdrop_dl.utils.utilities import log, log_spacer+from cyberdrop_dl.utils.constants import CSV_DELIMITER+from cyberdrop_dl.utils.logger import log, log_spacerif TYPE_CHECKING:from yarl import URLfrom cyberdrop_dl.managers.manager import Manager-CSV_DELIMITER = ","-class LogManager:def __init__(self, manager: Manager) -> None:diff --git a/cyberdrop_dl/managers/manager.py b/cyberdrop_dl/managers/manager.pyindex c0bda25f5..f9e7c441b 100644--- a/cyberdrop_dl/managers/manager.py+++ b/cyberdrop_dl/managers/manager.py@@ -3,6 +3,7 @@ from __future__ import annotationsimport copyimport jsonfrom dataclasses import field+from time import perf_counterfrom typing import TYPE_CHECKINGfrom cyberdrop_dl import __version__@@ -10,7 +11,6 @@ from cyberdrop_dl.managers.args_manager import ArgsManagerfrom cyberdrop_dl.managers.cache_manager import CacheManagerfrom cyberdrop_dl.managers.client_manager import ClientManagerfrom cyberdrop_dl.managers.config_manager import ConfigManager-from cyberdrop_dl.managers.console_manager import ConsoleManagerfrom cyberdrop_dl.managers.db_manager import DBManagerfrom cyberdrop_dl.managers.download_manager import DownloadManagerfrom cyberdrop_dl.managers.hash_manager import HashManager@@ -21,11 +21,11 @@ from cyberdrop_dl.managers.progress_manager import ProgressManagerfrom cyberdrop_dl.managers.realdebrid_manager import RealDebridManagerfrom cyberdrop_dl.utils.args import config_definitionsfrom cyberdrop_dl.utils.dataclasses.supported_domains import SupportedDomains+from cyberdrop_dl.utils.logger import logfrom cyberdrop_dl.utils.transfer.first_time_setup import TransitionManager-from cyberdrop_dl.utils.utilities import logif TYPE_CHECKING:- import asyncio+ from asyncio import TaskGroupfrom cyberdrop_dl.scraper.scraper import ScrapeMapper@@ -52,12 +52,13 @@ class Manager:self._loaded_args_config: bool = Falseself._made_portable: bool = False- self.task_group: asyncio.TaskGroup = field(init=False)+ self.task_group: TaskGroup = field(init=False)self.task_list: list = []self.scrape_mapper: ScrapeMapper = field(init=False)self.vi_mode: bool = False- self.console_manager: ConsoleManager = field(init=False)+ self.start_time: float = perf_counter()+ self.downloaded_data: int = 0def startup(self) -> None:"""Startup process for the manager."""@@ -124,14 +125,11 @@ class Manager:self.live_manager = LiveManager(self)if not isinstance(self.real_debrid_manager, RealDebridManager):self.real_debrid_manager = RealDebridManager(self)- if not isinstance(self.console_manager, ConsoleManager):- self.console_manager = ConsoleManager()- self.console_manager.startup()self.progress_manager = ProgressManager(self)await self.progress_manager.startup()# set files from args- from cyberdrop_dl.utils.utilities import MAX_NAME_LENGTHS+ from cyberdrop_dl.utils.constants import MAX_NAME_LENGTHSMAX_NAME_LENGTHS["FILE"] = int(self.config_manager.global_settings_data["General"]["max_file_name_length"])MAX_NAME_LENGTHS["FOLDER"] = int(self.config_manager.global_settings_data["General"]["max_folder_name_length"])@@ -146,9 +144,6 @@ class Manager:await self.hash_manager.startup()if not isinstance(self.live_manager, LiveManager):self.live_manager = LiveManager(self)- if not isinstance(self.console_manager, ConsoleManager):- self.console_manager = ConsoleManager()- self.console_manager.startup()self.progress_manager = ProgressManager(self)await self.progress_manager.startup()@@ -199,16 +194,13 @@ class Manager:str(print_settings["Sorting"]["scan_folder"]) if str(print_settings["Sorting"]["scan_folder"]) else "")- input_file = str(self.path_manager.input_file)- download_dir = str(self.path_manager.download_dir)-- log(f"Starting Cyberdrop-DL Process for {self.config_manager.loaded_config} Config", 10)+ log(f"Starting Cyberdrop-DL Process - Config: {self.config_manager.loaded_config}", 10)log(f"Running version {__version__}", 10)log(f"Using Config: {self.config_manager.loaded_config}", 10)- log(f"Using Config File: {self.config_manager.settings!s}", 10)- log(f"Using Input File: {input_file}", 10)- log(f"Using Download Folder: {download_dir}", 10)- log(f"Using History File: {self.path_manager.history_db!s}", 10)+ log(f"Using Config File: {self.config_manager.settings.resolve()}", 10)+ log(f"Using Input File: {self.path_manager.input_file.resolve()}", 10)+ log(f"Using Download Folder: {self.path_manager.download_dir.resolve()}", 10)+ log(f"Using History File: {self.path_manager.history_db.resolve()}", 10)log(f"Using Authentication: \n{json.dumps(auth_provided, indent=4, sort_keys=True)}", 10)log(f"Using Settings: \n{json.dumps(print_settings, indent=4, sort_keys=True)}", 10)@@ -220,8 +212,6 @@ class Manager:async def close(self) -> None:"""Closes the manager."""await self.db_manager.close()- self.console_manager.close()self.db_manager: DBManager = field(init=False)- self.console_manager: ConsoleManager = field(init=False)self.cache_manager: CacheManager = field(init=False)self.hash_manager: HashManager = field(init=False)diff --git a/cyberdrop_dl/managers/path_manager.py b/cyberdrop_dl/managers/path_manager.pyindex 6171ede9f..a34e723e7 100644--- a/cyberdrop_dl/managers/path_manager.py+++ b/cyberdrop_dl/managers/path_manager.py@@ -5,7 +5,7 @@ from datetime import datetimefrom pathlib import Pathfrom typing import TYPE_CHECKING-from cyberdrop_dl.utils.utilities import DEBUG_VAR+from cyberdrop_dl.utils.constants import DEBUG_VARif TYPE_CHECKING:from cyberdrop_dl.managers.manager import Managerdiff --git a/cyberdrop_dl/managers/progress_manager.py b/cyberdrop_dl/managers/progress_manager.pyindex 6209c0912..3ca2e9c4d 100644--- a/cyberdrop_dl/managers/progress_manager.py+++ b/cyberdrop_dl/managers/progress_manager.py@@ -13,7 +13,8 @@ from cyberdrop_dl.ui.progress.hash_progress import HashProgressfrom cyberdrop_dl.ui.progress.scraping_progress import ScrapingProgressfrom cyberdrop_dl.ui.progress.sort_progress import SortProgressfrom cyberdrop_dl.ui.progress.statistic_progress import DownloadStatsProgress, ScrapeStatsProgress-from cyberdrop_dl.utils.utilities import log, log_spacer, log_with_color, parse_bytes+from cyberdrop_dl.utils.logger import log, log_spacer, log_with_color+from cyberdrop_dl.utils.utilities import parse_bytesif TYPE_CHECKING:from cyberdrop_dl.managers.manager import Manager@@ -70,27 +71,27 @@ class ProgressManager:self.hash_layout = await self.hash_progress.get_hash_progress()self.sort_layout = await self.sort_progress.get_progress()- async def print_stats(self, start_time: timedelta | float) -> None:+ def print_stats(self, start_time: timedelta | float) -> None:"""Prints the stats of the program."""end_time = time.perf_counter()- total_time = timedelta(seconds=int(end_time - start_time))+ runtime = timedelta(seconds=int(end_time - start_time))downloaded_data, unit = parse_bytes(self.file_progress.downloaded_data)log("Printing Stats...\n", 20)- log_with_color("Run Stats:", "cyan", 20)- log_with_color(f" Total Runtime: {total_time}", "yellow", 20)+ log_with_color(f"Run Stats (config: {self.manager.config_manager.loaded_config}):", "cyan", 20)+ log_with_color(f" Total Runtime: {runtime}", "yellow", 20)log_with_color(f" Total Downloaded Data: {downloaded_data:.2f} {unit}", "yellow", 20)log_spacer(20, "")log_with_color("Download Stats:", "cyan", 20)- log_with_color(f" Downloaded {self.download_progress.completed_files} files", "green", 20)+ log_with_color(f" Downloaded: {self.download_progress.completed_files} files", "green", 20)log_with_color(- f" Previously Downloaded {self.download_progress.previously_completed_files} files",+ f" Skipped (Previously Downloaded): {self.download_progress.previously_completed_files} files","yellow",20,)- log_with_color(f" Skipped By Config {self.download_progress.skipped_files} files", "yellow", 20)- log_with_color(f" Failed {self.download_stats_progress.failed_files} files", "red", 20)+ log_with_color(f" Skipped (By Config): {self.download_progress.skipped_files} files", "yellow", 20)+ log_with_color(f" Failed: {self.download_stats_progress.failed_files} files", "red", 20)log_spacer(20, "")log_with_color("Unsupported URLs Stats:", "cyan", 20)@@ -99,14 +100,10 @@ class ProgressManager:log_spacer(20, "")log_with_color("Dupe Stats:", "cyan", 20)- log_with_color(f" Previously Hashed {self.hash_progress.prev_hashed_files} files", "yellow", 20)- log_with_color(f" Newly Hashed {self.hash_progress.hashed_files} files", "yellow", 20)- log_with_color(f" Removed From Current Downloads {self.hash_progress.removed_files} files", "yellow", 20)- log_with_color(- f" Removed From Previous Downloads {self.hash_progress.removed_prev_files} files",- "yellow",- 20,- )+ log_with_color(f" Previously Hashed: {self.hash_progress.prev_hashed_files} files", "yellow", 20)+ log_with_color(f" Newly Hashed: {self.hash_progress.hashed_files} files", "yellow", 20)+ log_with_color(f" Removed (Current Downloads): {self.hash_progress.removed_files} files", "yellow", 20)+ log_with_color(f" Removed (Previous Downloads): {self.hash_progress.removed_prev_files} files", "yellow", 20)log_spacer(20, "")log_with_color("Sort Stats:", "cyan", 20)@@ -115,18 +112,13 @@ class ProgressManager:log_with_color(f" Organized: {self.sort_progress.video_count} Videos", "green", 20)log_with_color(f" Organized: {self.sort_progress.other_count} Other Files", "green", 20)- scrape_failures = await self.scrape_stats_progress.return_totals()- log_spacer(20, "")- log_with_color("Scrape Failures:", "cyan", 20)- if not scrape_failures:- log_with_color(" None", "green", 20)- for key, value in scrape_failures.items():- log_with_color(f" ({key}): {value}", "red", 20)+ def log_failures(failures: dict, title: str = "Failures:") -> None:+ log_spacer(20, "")+ log_with_color(title, "cyan", 20)+ if not failures:+ log_with_color(" None", "green", 20)+ for name, count in failures.items():+ log_with_color(f" ({name}): {count}", "red", 20)- download_failures = await self.download_stats_progress.return_totals()- log_spacer(20, "")- log_with_color("Download Failures:", "cyan", 20)- if not download_failures:- log_with_color(" None", "green", 20)- for key, value in download_failures.items():- log_with_color(f" ({key}): {value}", "red", 20)+ log_failures(self.scrape_stats_progress.return_totals(), "Scrape Failures:")+ log_failures(self.download_stats_progress.return_totals(), "Download Failures:")diff --git a/cyberdrop_dl/managers/realdebrid_manager.py b/cyberdrop_dl/managers/realdebrid_manager.pyindex b506cccc4..8f567a88a 100644--- a/cyberdrop_dl/managers/realdebrid_manager.py+++ b/cyberdrop_dl/managers/realdebrid_manager.py@@ -8,7 +8,7 @@ from typing import TYPE_CHECKINGfrom cyberdrop_dl.managers.real_debrid.api import RealDebridApifrom cyberdrop_dl.managers.real_debrid.errors import RealDebridError-from cyberdrop_dl.utils.utilities import log+from cyberdrop_dl.utils.logger import logwarnings.simplefilter(action="ignore", category=FutureWarning)diff --git a/cyberdrop_dl/scraper/crawler.py b/cyberdrop_dl/scraper/crawler.pyindex 6a37e94e3..2c42096bc 100644--- a/cyberdrop_dl/scraper/crawler.py+++ b/cyberdrop_dl/scraper/crawler.py@@ -13,7 +13,8 @@ from cyberdrop_dl.clients.errors import LoginErrorfrom cyberdrop_dl.downloader.downloader import Downloaderfrom cyberdrop_dl.utils.database.tables.history_table import get_db_pathfrom cyberdrop_dl.utils.dataclasses.url_objects import MediaItem, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_download_path, log, remove_file_id+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_download_path, remove_file_idif TYPE_CHECKING:from cyberdrop_dl.clients.scraper_client import ScraperClientdiff --git a/cyberdrop_dl/scraper/crawlers/bunkrr_crawler.py b/cyberdrop_dl/scraper/crawlers/bunkrr_crawler.pyindex cf176a0ca..41368dbd7 100644--- a/cyberdrop_dl/scraper/crawlers/bunkrr_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/bunkrr_crawler.py@@ -11,8 +11,9 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenError, NoExtensionError, ScrapeErrorfrom cyberdrop_dl.scraper.crawler import Crawler+from cyberdrop_dl.utils.constants import FILE_FORMATSfrom cyberdrop_dl.utils.dataclasses.url_objects import FILE_HOST_ALBUM, ScrapeItem-from cyberdrop_dl.utils.utilities import FILE_FORMATS, error_handling_wrapper, get_filename_and_ext+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoup, Tagdiff --git a/cyberdrop_dl/scraper/crawlers/celebforum_crawler.py b/cyberdrop_dl/scraper/crawlers/celebforum_crawler.pyindex a00b51045..8a9f69133 100644--- a/cyberdrop_dl/scraper/crawlers/celebforum_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/celebforum_crawler.py@@ -9,7 +9,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FORUM, FORUM_POST, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoup, Tagdiff --git a/cyberdrop_dl/scraper/crawlers/coomer_crawler.py b/cyberdrop_dl/scraper/crawlers/coomer_crawler.pyindex 70008daff..fbbc210d2 100644--- a/cyberdrop_dl/scraper/crawlers/coomer_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/coomer_crawler.py@@ -207,7 +207,7 @@ class CoomerCrawler(Crawler):await self.parse_datetime(date),add_parent=add_parent,)- await new_scrape_item.add_to_parent_title(post_title)+ new_scrape_item.add_to_parent_title(post_title)self.manager.task_group.create_task(self.run(new_scrape_item))async def get_user_str_from_post(self, scrape_item: ScrapeItem) -> str:diff --git a/cyberdrop_dl/scraper/crawlers/cyberfile_crawler.py b/cyberdrop_dl/scraper/crawlers/cyberfile_crawler.pyindex 52cadf7e7..ba49a14e5 100644--- a/cyberdrop_dl/scraper/crawlers/cyberfile_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/cyberfile_crawler.py@@ -12,7 +12,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenError, PasswordProtectedError, ScrapeErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FILE_HOST_ALBUM, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from cyberdrop_dl.managers.manager import Managerdiff --git a/cyberdrop_dl/scraper/crawlers/ehentai_crawler.py b/cyberdrop_dl/scraper/crawlers/ehentai_crawler.pyindex 0bbba6c05..db0ac040f 100644--- a/cyberdrop_dl/scraper/crawlers/ehentai_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/ehentai_crawler.py@@ -11,7 +11,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FILE_HOST_ALBUM, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoupdiff --git a/cyberdrop_dl/scraper/crawlers/f95zone_crawler.py b/cyberdrop_dl/scraper/crawlers/f95zone_crawler.pyindex 077a59fc5..640aaa047 100644--- a/cyberdrop_dl/scraper/crawlers/f95zone_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/f95zone_crawler.py@@ -9,7 +9,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FORUM, FORUM_POST, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoup, Tagdiff --git a/cyberdrop_dl/scraper/crawlers/gofile_crawler.py b/cyberdrop_dl/scraper/crawlers/gofile_crawler.pyindex 4c245aa07..19420935b 100644--- a/cyberdrop_dl/scraper/crawlers/gofile_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/gofile_crawler.py@@ -19,7 +19,8 @@ from cyberdrop_dl.clients.errors import ()from cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FILE_HOST_ALBUM, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from cyberdrop_dl.clients.scraper_client import ScraperClient@@ -136,7 +137,7 @@ class GoFileCrawler(Crawler):duplicate_scrape_item = deepcopy(scrape_item)duplicate_scrape_item.possible_datetime = content["createTime"]duplicate_scrape_item.part_of_album = True- await duplicate_scrape_item.add_to_parent_title(title)+ duplicate_scrape_item.add_to_parent_title(title)await self.handle_file(link, duplicate_scrape_item, filename, ext)except NoExtensionError:log(f"Scrape Failed: {link} (No File Extension)", 40)diff --git a/cyberdrop_dl/scraper/crawlers/hotpic_crawler.py b/cyberdrop_dl/scraper/crawlers/hotpic_crawler.pyindex 7d0cceeaa..7dbdf04dd 100644--- a/cyberdrop_dl/scraper/crawlers/hotpic_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/hotpic_crawler.py@@ -9,7 +9,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FILE_HOST_ALBUM, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoupdiff --git a/cyberdrop_dl/scraper/crawlers/imgur_crawler.py b/cyberdrop_dl/scraper/crawlers/imgur_crawler.pyindex 034c0d6c7..4e3c36859 100644--- a/cyberdrop_dl/scraper/crawlers/imgur_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/imgur_crawler.py@@ -9,7 +9,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import LoginError, MaxChildrenError, ScrapeErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FILE_HOST_ALBUM, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from cyberdrop_dl.managers.manager import Managerdiff --git a/cyberdrop_dl/scraper/crawlers/kemono_crawler.py b/cyberdrop_dl/scraper/crawlers/kemono_crawler.pyindex 754a63c43..25acc9ea0 100644--- a/cyberdrop_dl/scraper/crawlers/kemono_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/kemono_crawler.py@@ -262,7 +262,7 @@ class KemonoCrawler(Crawler):await self.parse_datetime(date),add_parent=add_parent,)- await new_scrape_item.add_to_parent_title(post_title)+ new_scrape_item.add_to_parent_title(post_title)self.manager.task_group.create_task(self.run(new_scrape_item))@error_handling_wrapperdiff --git a/cyberdrop_dl/scraper/crawlers/leakedmodels_crawler.py b/cyberdrop_dl/scraper/crawlers/leakedmodels_crawler.pyindex d42ebcd72..af357bae5 100644--- a/cyberdrop_dl/scraper/crawlers/leakedmodels_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/leakedmodels_crawler.py@@ -9,7 +9,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FORUM, FORUM_POST, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoup, Tagdiff --git a/cyberdrop_dl/scraper/crawlers/nekohouse_crawler.py b/cyberdrop_dl/scraper/crawlers/nekohouse_crawler.pyindex aed9ebecc..c5ac6be95 100644--- a/cyberdrop_dl/scraper/crawlers/nekohouse_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/nekohouse_crawler.py@@ -279,7 +279,7 @@ class NekohouseCrawler(Crawler):await self.parse_datetime(date),add_parent=add_parent,)- await new_scrape_item.add_to_parent_title(post_title)+ new_scrape_item.add_to_parent_title(post_title)self.manager.task_group.create_task(self.run(new_scrape_item))async def get_maximum_offset(self, soup: BeautifulSoup) -> int:diff --git a/cyberdrop_dl/scraper/crawlers/nudostar_crawler.py b/cyberdrop_dl/scraper/crawlers/nudostar_crawler.pyindex e6f591cf1..7b76fbc0c 100644--- a/cyberdrop_dl/scraper/crawlers/nudostar_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/nudostar_crawler.py@@ -10,7 +10,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FORUM, FORUM_POST, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoup, Tagdiff --git a/cyberdrop_dl/scraper/crawlers/omegascans_crawler.py b/cyberdrop_dl/scraper/crawlers/omegascans_crawler.pyindex a15c7dea6..61f0d6266 100644--- a/cyberdrop_dl/scraper/crawlers/omegascans_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/omegascans_crawler.py@@ -11,7 +11,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenError, ScrapeErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FILE_HOST_ALBUM, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoupdiff --git a/cyberdrop_dl/scraper/crawlers/realbooru_crawler.py b/cyberdrop_dl/scraper/crawlers/realbooru_crawler.pyindex 32198a23f..648d7d998 100644--- a/cyberdrop_dl/scraper/crawlers/realbooru_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/realbooru_crawler.py@@ -9,7 +9,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FILE_HOST_ALBUM, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoupdiff --git a/cyberdrop_dl/scraper/crawlers/realdebrid_crawler.py b/cyberdrop_dl/scraper/crawlers/realdebrid_crawler.pyindex 0b649ef88..8163fc2e2 100644--- a/cyberdrop_dl/scraper/crawlers/realdebrid_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/realdebrid_crawler.py@@ -8,7 +8,8 @@ from yarl import URLfrom cyberdrop_dl.managers.real_debrid.api import RATE_LIMITfrom cyberdrop_dl.scraper.crawler import Crawler-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from cyberdrop_dl.managers.manager import Managerdiff --git a/cyberdrop_dl/scraper/crawlers/reddit_crawler.py b/cyberdrop_dl/scraper/crawlers/reddit_crawler.pyindex 2ea0b58d8..920ee874d 100644--- a/cyberdrop_dl/scraper/crawlers/reddit_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/reddit_crawler.py@@ -12,7 +12,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenError, NoExtensionError, ScrapeErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FILE_HOST_ALBUM, FILE_HOST_PROFILE, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from asyncpraw.models import Redditor, Submission, Subreddit@@ -223,5 +224,5 @@ class RedditCrawler(Crawler):add_parent=add_parent,)if self.manager.config_manager.settings_data["Download_Options"]["separate_posts"]:- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item.add_to_parent_title(title)return new_scrape_itemdiff --git a/cyberdrop_dl/scraper/crawlers/rule34xxx_crawler.py b/cyberdrop_dl/scraper/crawlers/rule34xxx_crawler.pyindex 6d572a9e2..fb61237bf 100644--- a/cyberdrop_dl/scraper/crawlers/rule34xxx_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/rule34xxx_crawler.py@@ -9,7 +9,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FILE_HOST_ALBUM, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoupdiff --git a/cyberdrop_dl/scraper/crawlers/scrolller_crawler.py b/cyberdrop_dl/scraper/crawlers/scrolller_crawler.pyindex c881e0cc4..054c65d6b 100644--- a/cyberdrop_dl/scraper/crawlers/scrolller_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/scrolller_crawler.py@@ -10,7 +10,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FILE_HOST_ALBUM, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from cyberdrop_dl.managers.manager import Managerdiff --git a/cyberdrop_dl/scraper/crawlers/simpcity_crawler.py b/cyberdrop_dl/scraper/crawlers/simpcity_crawler.pyindex 9fbe697ec..ca7ad4cd4 100644--- a/cyberdrop_dl/scraper/crawlers/simpcity_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/simpcity_crawler.py@@ -10,7 +10,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FORUM, FORUM_POST, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoup, Tagdiff --git a/cyberdrop_dl/scraper/crawlers/socialmediagirls_crawler.py b/cyberdrop_dl/scraper/crawlers/socialmediagirls_crawler.pyindex 1c36fdc19..b6557ddac 100644--- a/cyberdrop_dl/scraper/crawlers/socialmediagirls_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/socialmediagirls_crawler.py@@ -10,7 +10,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FORUM, FORUM_POST, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoup, Tagdiff --git a/cyberdrop_dl/scraper/crawlers/xbunker_crawler.py b/cyberdrop_dl/scraper/crawlers/xbunker_crawler.pyindex 9eb79d67f..a2d28f128 100644--- a/cyberdrop_dl/scraper/crawlers/xbunker_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/xbunker_crawler.py@@ -10,7 +10,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FORUM, FORUM_POST, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoup, Tagdiff --git a/cyberdrop_dl/scraper/crawlers/xbunkr_crawler.py b/cyberdrop_dl/scraper/crawlers/xbunkr_crawler.pyindex 4ce0d5967..a6ca5cd15 100644--- a/cyberdrop_dl/scraper/crawlers/xbunkr_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/xbunkr_crawler.py@@ -9,7 +9,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import MaxChildrenError, NoExtensionErrorfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import FILE_HOST_ALBUM, ScrapeItem-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from bs4 import BeautifulSoupdiff --git a/cyberdrop_dl/scraper/crawlers/xxxbunker_crawler.py b/cyberdrop_dl/scraper/crawlers/xxxbunker_crawler.pyindex 37f9f8664..3fb1ec661 100644--- a/cyberdrop_dl/scraper/crawlers/xxxbunker_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/xxxbunker_crawler.py@@ -12,7 +12,8 @@ from yarl import URLfrom cyberdrop_dl.clients.errors import ScrapeErrorfrom cyberdrop_dl.scraper.crawler import Crawler-from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_extif TYPE_CHECKING:from cyberdrop_dl.managers.manager import Managerdiff --git a/cyberdrop_dl/scraper/filters.py b/cyberdrop_dl/scraper/filters.pyindex 88aeef3b3..d9ecd3a62 100644--- a/cyberdrop_dl/scraper/filters.py+++ b/cyberdrop_dl/scraper/filters.py@@ -6,15 +6,13 @@ import arrowfrom yarl import URLfrom cyberdrop_dl.clients.errors import NoExtensionError-from cyberdrop_dl.utils.utilities import FILE_FORMATS, get_filename_and_ext+from cyberdrop_dl.utils.constants import FILE_FORMATS+from cyberdrop_dl.utils.utilities import get_filename_and_extif TYPE_CHECKING:from cyberdrop_dl.utils.dataclasses.url_objects import ScrapeItem-BLOCKED_DOMAINS = ("facebook", "instagram", "fbcdn")--def is_valid_url(scrape_item: ScrapeItem) -> bool:if not scrape_item.url:return False@@ -37,18 +35,14 @@ def is_outside_date_range(scrape_item: ScrapeItem, before: arrow, after: arrow)item_date = scrape_item.completed_at or scrape_item.created_atif not item_date:return False- if after and arrow.get(item_date) < after:- skip = True- elif before and arrow.get(item_date) > before:+ if after and arrow.get(item_date) < after or before and arrow.get(item_date) > before:skip = Truereturn skipdef is_in_domain_list(scrape_item: ScrapeItem, domain_list: list[str]) -> bool:- if any(domain in scrape_item.url.host for domain in domain_list):- return True- return False+ return any(domain in scrape_item.url.host for domain in domain_list)def remove_trailing_slash(url: URL) -> URL:diff --git a/cyberdrop_dl/scraper/jdownloader.py b/cyberdrop_dl/scraper/jdownloader.pyindex 2b1889955..90374bdd6 100644--- a/cyberdrop_dl/scraper/jdownloader.py+++ b/cyberdrop_dl/scraper/jdownloader.py@@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, Callablefrom myjdapi import myjdapifrom cyberdrop_dl.clients.errors import JDownloaderError-from cyberdrop_dl.utils.utilities import log+from cyberdrop_dl.utils.logger import logif TYPE_CHECKING:from yarl import URLdiff --git a/cyberdrop_dl/scraper/scraper.py b/cyberdrop_dl/scraper/scraper.pyindex 38a3c6aa9..997d378ed 100644--- a/cyberdrop_dl/scraper/scraper.py+++ b/cyberdrop_dl/scraper/scraper.py@@ -20,17 +20,16 @@ from cyberdrop_dl.scraper.filters import (remove_trailing_slash,)from cyberdrop_dl.scraper.jdownloader import JDownloader+from cyberdrop_dl.utils.constants import BLOCKED_DOMAINSfrom cyberdrop_dl.utils.dataclasses.url_objects import MediaItem, ScrapeItem-from cyberdrop_dl.utils.utilities import get_download_path, get_filename_and_ext, log+from cyberdrop_dl.utils.logger import log+from cyberdrop_dl.utils.utilities import get_download_path, get_filename_and_extif TYPE_CHECKING:from cyberdrop_dl.managers.manager import Managerfrom cyberdrop_dl.scraper.crawler import Crawler-BLOCKED_DOMAINS = ("facebook", "instagram", "fbcdn")--class ScrapeMapper:"""This class maps links to their respective handlers, or JDownloader if they are unsupported."""@@ -413,7 +412,7 @@ class ScrapeMapper:return yarl_linksasync def parse_input_file_groups(self) -> dict[str, URL]:- "Split URLs from input file by their groups"+ """Split URLs from input file by their groups"""input_file = self.manager.path_manager.input_filelinks = {"": []}block_quote = False@@ -444,7 +443,7 @@ class ScrapeMapper:links = {"": []}if not self.manager.args_manager.other_links:- links = self.parse_input_file_groups()+ links = await self.parse_input_file_groups()else:links[""].extend(self.manager.args_manager.other_links)@@ -457,9 +456,9 @@ class ScrapeMapper:for title in links:for url in links[title]:item = self.create_item_from_link(url)- await item.add_to_parent_title(title)+ item.add_to_parent_title(title)item.part_of_album = True- if await self.filter_items(item):+ if self.filter_items(item):items.append(item)for item in items:self.manager.task_group.create_task(self.send_to_crawler(item))@@ -470,7 +469,7 @@ class ScrapeMapper:items = []for entry in entries:item = self.create_item_from_entry(entry)- if await self.filter_items(item):+ if self.filter_items(item):items.append(item)if self.manager.args_manager.max_items:items = items[: self.manager.args_manager.max_items]@@ -486,7 +485,7 @@ class ScrapeMapper:items = []for entry in entries:item = self.create_item_from_entry(entry)- if await self.filter_items(item):+ if self.filter_items(item):items.append(item)if self.manager.args_manager.max_items:items = items[: self.manager.args_manager.max_items]@@ -500,7 +499,7 @@ class ScrapeMapper:items = []for entry in entries:item = self.create_item_from_entry(entry)- if await self.filter_items(item):+ if self.filter_items(item):items.append(item)if self.manager.args_manager.max_items:items = items[: self.manager.args_manager.max_items]@@ -510,10 +509,10 @@ class ScrapeMapper:"""~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""async def filter_and_send_to_crawler(self, scrape_item: ScrapeItem) -> None:- "Send scrape_item to a supported crawler."+ """Send scrape_item to a supported crawler."""if not isinstance(scrape_item.url, URL):scrape_item.url = URL(scrape_item.url)- if await self.filter_items(scrape_item):+ if self.filter_items(scrape_item):await self.send_to_crawler(scrape_item)@staticmethod@@ -583,7 +582,8 @@ class ScrapeMapper:except JDownloaderError as e:log(f"Failed to send {scrape_item.url} to JDownloader\n{e.message}", 40)await self.manager.log_manager.write_unsupported_urls_log(- scrape_item.url, next(scrape_item.parents, None)+ scrape_item.url,+ next(scrape_item.parents, None),)await self.manager.progress_manager.scrape_stats_progress.add_unsupported(sent_to_jdownloader=success)return@@ -592,9 +592,8 @@ class ScrapeMapper:await self.manager.log_manager.write_unsupported_urls_log(scrape_item.url, next(scrape_item.parents, None))await self.manager.progress_manager.scrape_stats_progress.add_unsupported()- async def filter_items(self, scrape_item: ScrapeItem) -> bool:- """Pre-filter scrape items base on URL blocks."""-+ def filter_items(self, scrape_item: ScrapeItem) -> bool:+ """Pre-filter scrape items base on URL."""if not is_valid_url(scrape_item):return False@@ -613,7 +612,7 @@ class ScrapeMapper:log(f"Skipping URL by skip_hosts config: {scrape_item.url}", 10)return False- only_hosts = self.manager.config_manager.settings_data["Ignore_Options"]["skip_hosts"]+ only_hosts = self.manager.config_manager.settings_data["Ignore_Options"]["only_hosts"]if only_hosts and not is_in_domain_list(scrape_item, only_hosts):log(f"Skipping URL by only_hosts config: {scrape_item.url}", 10)return Falsediff --git a/cyberdrop_dl/ui/progress/statistic_progress.py b/cyberdrop_dl/ui/progress/statistic_progress.pyindex f0e644460..19c0c42c6 100644--- a/cyberdrop_dl/ui/progress/statistic_progress.py+++ b/cyberdrop_dl/ui/progress/statistic_progress.py@@ -100,7 +100,7 @@ class DownloadStatsProgress:)await self.update_total(self.failed_files)- async def return_totals(self) -> dict:+ def return_totals(self) -> dict:"""Returns the total number of failed files."""failures = {}for failure_type, task_id in self.failure_types.items():@@ -183,7 +183,7 @@ class ScrapeStatsProgress:else:self.unsupported_urls_skipped += 1- async def return_totals(self) -> dict:+ def return_totals(self) -> dict:"""Returns the total number of failed sites and reasons."""failures = {}for failure_type, task_id in self.failure_types.items():diff --git a/cyberdrop_dl/ui/prompts/general_prompts.py b/cyberdrop_dl/ui/prompts/general_prompts.pyindex 91dfcf58d..64bd4be3c 100644--- a/cyberdrop_dl/ui/prompts/general_prompts.py+++ b/cyberdrop_dl/ui/prompts/general_prompts.py@@ -11,9 +11,9 @@ from InquirerPy.separator import Separatorfrom InquirerPy.validator import EmptyInputValidator, PathValidatorfrom rich.console import Console+from cyberdrop_dl.utils.logger import logfrom cyberdrop_dl.utils.transfer.transfer_v4_config import transfer_v4_configfrom cyberdrop_dl.utils.transfer.transfer_v4_db import transfer_v4_db-from cyberdrop_dl.utils.utilities import logif TYPE_CHECKING:from cyberdrop_dl.managers.manager import Managerdiff --git a/cyberdrop_dl/utils/args/args.py b/cyberdrop_dl/utils/args/args.pyindex b0926af81..c526ec082 100644--- a/cyberdrop_dl/utils/args/args.py+++ b/cyberdrop_dl/utils/args/args.py@@ -63,6 +63,7 @@ def parse_args() -> argparse.Namespace:file_paths.add_argument("--config-file", type=str, help="path to the CDL settings.yaml file to load", default="")file_paths.add_argument("--appdata-folder",+ dest="appdata_dir",type=str,help="path to where you want CDL to store it's AppData folder",default="",diff --git a/cyberdrop_dl/utils/constants.py b/cyberdrop_dl/utils/constants.pyindex 179150b9e..160527f60 100644--- a/cyberdrop_dl/utils/constants.py+++ b/cyberdrop_dl/utils/constants.py@@ -3,13 +3,25 @@ from enum import IntEnumfrom rich.text import Text+# logging+CONSOLE_LEVEL = 100MAX_NAME_LENGTHS = {"FILE": 95, "FOLDER": 60}-DEFAULT_CONSOLE_WIDTH = 240DEBUG_VAR = FalseCONSOLE_DEBUG_VAR = False-+CSV_DELIMITER = ","LOG_OUTPUT_TEXT = Text("")+RICH_HANDLER_CONFIG = {"show_time": True, "rich_tracebacks": True, "tracebacks_show_locals": False}+RICH_HANDLER_DEBUG_CONFIG = {+ "show_time": True,+ "rich_tracebacks": True,+ "tracebacks_show_locals": True,+ "locals_max_string": DEFAULT_CONSOLE_WIDTH,+ "tracebacks_extra_lines": 2,+ "locals_max_length": 20,+}++BLOCKED_DOMAINS = ("facebook", "instagram", "fbcdn")# regexRAR_MULTIPART_PATTERN = re.compile(r"^part\d+")diff --git a/cyberdrop_dl/utils/database/tables/temp_table.py b/cyberdrop_dl/utils/database/tables/temp_table.pyindex 50e47cd95..9b1597725 100644--- a/cyberdrop_dl/utils/database/tables/temp_table.py+++ b/cyberdrop_dl/utils/database/tables/temp_table.py@@ -5,12 +5,12 @@ from typing import TYPE_CHECKINGfrom cyberdrop_dl.utils.database.table_definitions import create_tempif TYPE_CHECKING:- import aiosqlite+ from aiosqlite import Connectionclass TempTable:- def __init__(self, db_conn: aiosqlite.Connection) -> None:- self.db_conn: aiosqlite.Connection = db_conn+ def __init__(self, db_conn: Connection) -> None:+ self.db_conn: Connection = db_connasync def startup(self) -> None:"""Startup process for the TempTable."""diff --git a/cyberdrop_dl/utils/logger.py b/cyberdrop_dl/utils/logger.pyindex ea73719da..836effed5 100644--- a/cyberdrop_dl/utils/logger.py+++ b/cyberdrop_dl/utils/logger.py@@ -2,65 +2,59 @@ from __future__ import annotationsimport logging-import rich+from rich.console import Consolefrom rich.text import Text-from cyberdrop_dl.managers.console_manager import log as log_console-from cyberdrop_dl.utils.constants import CONSOLE_DEBUG_VAR, DEBUG_VAR, DEFAULT_CONSOLE_WIDTH+from cyberdrop_dl.utils import constantslogger = logging.getLogger("cyberdrop_dl")logger_debug = logging.getLogger("cyberdrop_dl_debug")-def log(message: Exception | str, level: int = 10, sleep: int | None = None, **kwargs) -> None:+console = Console()+++def print_to_console(text: Text | str) -> None:+ console.print(text)+++def log(message: Exception | str, level: int = 10, *, sleep: int | None = None, **kwargs) -> None:"""Simple logging function."""logger.log(level, message, **kwargs)- if DEBUG_VAR:- logger_debug.log(level, message, **kwargs)- log_console(level, message, sleep=sleep)+ log_debug(message, level, **kwargs)+ log_debug_console(message, level, sleep=sleep, **kwargs)def log_debug(message: Exception | str, level: int = 10, *kwargs) -> None:"""Simple logging function."""- if DEBUG_VAR:+ if constants.DEBUG_VAR:message = str(message)logger_debug.log(level, message.encode("ascii", "ignore").decode("ascii"), *kwargs)def log_debug_console(message: Exception | str, level: int, sleep: int | None = None) -> None:- if CONSOLE_DEBUG_VAR:+ if constants.CONSOLE_DEBUG_VAR:message = str(message)- log_console(level, message.encode("ascii", "ignore").decode("ascii"), sleep=sleep)+ _log_to_console(level, message.encode("ascii", "ignore").decode("ascii"), sleep=sleep)def log_with_color(message: str, style: str, level: int, show_in_stats: bool = True, *kwargs) -> None:"""Simple logging function with color."""- global LOG_OUTPUT_TEXT- logger.log(level, message, *kwargs)+ log(message, level, *kwargs)text = Text(message, style=style)- if DEBUG_VAR:- logger_debug.log(level, message, *kwargs)- rich.print(text)+ console.print(text)if show_in_stats:- LOG_OUTPUT_TEXT.append_text(text.append("\n"))+ constants.LOG_OUTPUT_TEXT.append_text(text.append("\n"))-def get_log_output_text() -> str:- return LOG_OUTPUT_TEXT---def set_log_output_text(text: Text | str) -> None:- global LOG_OUTPUT_TEXT- if isinstance(text, str):- text = Text(text)- LOG_OUTPUT_TEXT = text+def log_spacer(level: int, char: str = "-") -> None:+ spacer = char * min(int(constants.DEFAULT_CONSOLE_WIDTH / 2), 50)+ log(spacer, level)+ console.print("")+ constants.LOG_OUTPUT_TEXT.append("\n", style="black")-def log_spacer(level: int, char: str = "-") -> None:- global LOG_OUTPUT_TEXT- spacer = char * min(int(DEFAULT_CONSOLE_WIDTH / 2), 50)- rich.print("")- LOG_OUTPUT_TEXT.append("\n", style="black")- logger.log(level, spacer)- if DEBUG_VAR:- logger_debug.log(level, spacer)+def _log_to_console(level: int, record: str, *_, **__) -> None:+ level = level or 10+ if level >= constants.CONSOLE_LEVEL:+ console.log(record)diff --git a/cyberdrop_dl/utils/sorting.py b/cyberdrop_dl/utils/sorting.pyindex 7ec60e412..d16d1adfc 100644--- a/cyberdrop_dl/utils/sorting.py+++ b/cyberdrop_dl/utils/sorting.py@@ -12,7 +12,9 @@ from filedate import Filefrom PIL import Imagefrom videoprops import get_audio_properties, get_video_properties-from cyberdrop_dl.utils.utilities import FILE_FORMATS, log, log_with_color, purge_dir_tree+from cyberdrop_dl.utils.constants import FILE_FORMATS+from cyberdrop_dl.utils.logger import log, log_with_color+from cyberdrop_dl.utils.utilities import purge_dir_treeif TYPE_CHECKING:from cyberdrop_dl.managers.manager import Managerdiff --git a/cyberdrop_dl/utils/utilities.py b/cyberdrop_dl/utils/utilities.pyindex d238cdf2e..7db7c33c6 100644--- a/cyberdrop_dl/utils/utilities.py+++ b/cyberdrop_dl/utils/utilities.py@@ -6,7 +6,7 @@ import osimport refrom functools import wrapsfrom pathlib import Path-from typing import TYPE_CHECKING, Any, Callable+from typing import TYPE_CHECKING, Callableimport aiofilesimport apprise@@ -15,10 +15,10 @@ from aiohttp import ClientSession, FormDatafrom rich.text import Textfrom yarl import URL-import cyberdrop_dl.utils.constants as constantsfrom cyberdrop_dl.clients.errors import CDLBaseError, NoExtensionErrorfrom cyberdrop_dl.managers.real_debrid.errors import RealDebridError-from cyberdrop_dl.utils.logger import get_log_output_text, log, log_with_color, set_log_output_text+from cyberdrop_dl.utils import constants+from cyberdrop_dl.utils.logger import log, log_with_colorif TYPE_CHECKING:from cyberdrop_dl.managers.manager import Manager@@ -26,7 +26,7 @@ if TYPE_CHECKING:from cyberdrop_dl.utils.dataclasses.url_objects import ScrapeItem-def error_handling_wrapper(func: Callable) -> Any:+def error_handling_wrapper(func: Callable) -> None:"""Wrapper handles errors for url scraping."""@wraps(func)@@ -145,6 +145,27 @@ def remove_file_id(manager: Manager, filename: str, ext: str) -> tuple[str, str]"""~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""+def parse_bytes(size: int) -> tuple[int, str]:+ """Get human repr of bytes as a tuple of (VALUE , UNIT)"""+ for unit in ["B", "KB", "MB", "GB", "TB", "PB", "EB"]:+ if size < 1024:+ return size, unit+ size /= 1024+ return size, "YB"+++def parse_rich_text_by_style(text: Text, style_map: dict, default_style_map_key: str = "default") -> str:+ """Returns `text` as a plain str, parsing each tag in text acording to `style_map`."""+ plain_text = ""+ for span in text.spans:+ span_text = text.plain[span.start : span.end].rstrip("\n")+ plain_line: str = style_map.get(span.style) or style_map.get(default_style_map_key)+ if plain_line:+ plain_text += plain_line.format(span_text) + "\n"++ return plain_text++def purge_dir_tree(dirname: Path) -> None:"""Purges empty files and directories."""for file in dirname.rglob("*"):@@ -173,11 +194,7 @@ async def check_partials_and_empty_folders(manager: Manager) -> None:temp_downloads = any(Path(f).is_file() for f in await manager.db_manager.temp_table.get_temp_names())if temp_downloads:msg = "There are partial downloads from the previous run, please re-run the program."- log_with_color(- msg,- "yellow",- 20,- )+ log_with_color(msg, "yellow", 20)if not manager.config_manager.settings_data["Runtime_Options"]["skip_check_for_empty_folders"]:log_with_color("Checking for empty folders...", "yellow", 20)@@ -186,7 +203,7 @@ async def check_partials_and_empty_folders(manager: Manager) -> None:purge_dir_tree(manager.path_manager.sorted_dir)-def check_latest_pypi(log_to_console: bool = True, call_from_ui: bool = False) -> tuple[str]:+def check_latest_pypi(log_to_console: bool = True, call_from_ui: bool = False) -> tuple[str, str]:"""Checks if the current version is the latest version."""import json@@ -201,27 +218,23 @@ def check_latest_pypi(log_to_console: bool = True, call_from_ui: bool = False) -latest_version: str = data["info"]["version"]releases = data["releases"].keys()message = color = None-is_prelease, message = check_prelease_version(current_version, releases)if current_version not in releases:message = Text("You are on an unreleased version, skipping version check")color = "bold_yellow"-elif is_prelease:color = "bold_red"-elif current_version != latest_version:message = f"A new version of Cyberdrop-DL is available: [cyan]{latest_version}[/cyan]"message = Text.from_markup(message)-else:message = Text("You are currently on the latest version of Cyberdrop-DL")if call_from_ui:rich.print(message)elif log_to_console:- log_with_color(message.plain, color, 30)+ log_with_color(message.plain, color, 30, show_in_stats=False)return current_version, latest_version@@ -248,7 +261,7 @@ def check_prelease_version(current_version: str, releases: list[str]) -> tuple[sui_tag = constants.PRELEASE_TAGS.get(test_tag, "Testing").lower()if current_version != latest_testing_version:- message = f"A new {ui_tag} version of Cyberdrop-DL is available:"+ message = f"A new {ui_tag} version of Cyberdrop-DL is available: "message = Text(message).append_text(latest_testing_version)else:message = f"You are currently on the latest {ui_tag} version of [b cyan]{major_version}.{minor_version}.{patch_version}[/b cyan]"@@ -257,18 +270,16 @@ def check_prelease_version(current_version: str, releases: list[str]) -> tuple[sreturn latest_testing_version, message-async def sent_apprise_notifications(manager: Manager) -> None:+def sent_apprise_notifications(manager: Manager) -> None:apprise_file = manager.path_manager.config_dir / manager.config_manager.loaded_config / "apprise.txt"-- text: Text = get_log_output_text()- set_log_output_text("")+ text: Text = constants.LOG_OUTPUT_TEXT+ constants.LOG_OUTPUT_TEXT = Text("")if not apprise_file.is_file():return- async with aiofiles.open(apprise_file, encoding="utf8") as file:- lines = await file.readlines()- lines = [line.strip() for line in lines]+ with apprise_file.open(encoding="utf8") as file:+ lines = [line.strip() for line in file]if not lines:return@@ -285,7 +296,6 @@ async def sent_apprise_notifications(manager: Manager) -> None:apprise_obj.add(url, tag=tags)results = []-result = apprise_obj.notify(body=text.plain,title="Cyberdrop-DL",@@ -319,27 +329,6 @@ async def sent_apprise_notifications(manager: Manager) -> None:rich.print("Apprise notifications results:", result)-def parse_bytes(size: int) -> tuple[int, str]:- """Get human repr of bytes as a tuple of (VALUE , UNIT)"""- for unit in ["B", "KB", "MB", "GB", "TB", "PB", "EB"]:- if size < 1024:- return size, unit- size /= 1024- return size, "YB"---def parse_rich_text_by_style(text: Text, style_map: dict, default_style_map_key: str = "default") -> str:- """Returns `text` as a plain str, parsing each tag in text acording to `style_map`."""- plain_text = ""- for span in text.spans:- span_text = text.plain[span.start : span.end].rstrip("\n")- plain_line: str = style_map.get(span.style) or style_map.get(default_style_map_key)- if plain_line:- plain_text += plain_line.format(span_text) + "\n"-- return plain_text--async def send_webhook_message(manager: Manager) -> None:"""Outputs the stats to a code block for webhook messages."""webhook_url: str = manager.config_manager.settings_data["Logs"]["webhook_url"]@@ -355,7 +344,7 @@ async def send_webhook_message(manager: Manager) -> None:tags = tags.split(",")url = URL(url)- text: Text = get_log_output_text()+ text: Text = constants.LOG_OUTPUT_TEXTplain_text = parse_rich_text_by_style(text, constants.STYLE_TO_DIFF_FORMAT_MAP)main_log = manager.path_manager.main_log