mirror of
https://github.com/darkzoul5/YoutubePlaylistSync.git
synced 2026-09-22 06:12:21 +03:00
Introduce Logging and argparse libs
This commit is contained in:
+10
-5
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user