mirror of
https://github.com/darkzoul5/YoutubePlaylistSync.git
synced 2026-11-06 08:05:12 +02:00
Introduce Logging and argparse libs
This commit is contained in:
1 parent
b64e39a95f
commit
1402af52d6
4 files changed
+104
-69
No files matched your search
+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