Introduce Logging and argparse libs

This commit is contained in:
2025-10-21 21:41:03 +03:00
parent b64e39a95f
commit 1402af52d6
4 changed files with 104 additions and 69 deletions
+10 -5
View File
@@ -1,20 +1,25 @@
import time
import logging
from .downloader import PlaylistDownloader
class PlaylistManager:
def __init__(self, config):
def __init__(self, config, debug: bool = False):
self.logger = logging.getLogger(__name__)
self.config = config
# store debug on config so PlaylistDownloader __init__ can pick it up
setattr(self.config, "debug", bool(debug))
self.playlists = [PlaylistDownloader(config, pl, idx) for idx, pl in enumerate(config.playlists)]
def run(self):
total_connections = self.config.max_parallel_downloads * self.config.aria2c_connections
if total_connections > 100:
print(
"\033[91m"
f"⚠[WARNING] Total connections ({self.config.max_parallel_downloads} × {self.config.aria2c_connections} = {total_connections}) may overload your network! Pausing 5 seconds..."
"\033[0m"
self.logger.warning(
"Total connections (%d × %d = %d) may overload your network! Pausing 5 seconds...",
self.config.max_parallel_downloads,
self.config.aria2c_connections,
total_connections,
)
time.sleep(5)