Refactor YouTube Playlist Downloader

- Moved main execution logic to cli.py and updated imports accordingly.
- Created a new __init__.py file to export the main function from the cli module.
- Implemented the PlaylistDownloader class in downloader.py to handle playlist downloading logic.
- Added ConfigLoader class in config.py to manage configuration settings.
- Introduced PlaylistManager class in manager.py to manage multiple playlists.
- Updated encoding handling for Windows in the main execution block.
- Removed redundant code and improved overall structure for better readability and maintainability.
This commit is contained in:
2025-10-19 17:50:14 +03:00
parent f41e82e17a
commit 41359edc51
6 changed files with 553 additions and 601 deletions
+22
View File
@@ -0,0 +1,22 @@
import time
from .downloader import PlaylistDownloader
class PlaylistManager:
def __init__(self, config):
self.config = config
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"
)
time.sleep(5)
for playlist in self.playlists:
playlist.update()