Files
YoutubePlaylistSync/ytplaylist/manager.py
T

28 lines
995 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import time
import logging
from .downloader import PlaylistDownloader
class PlaylistManager:
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:
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)
for playlist in self.playlists:
playlist.update()