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 subprocess
from .config import ConfigLoader, is_docker
from .manager import PlaylistManager
def update_yt_dlp(yt_dlp_path: str):
try:
subprocess.run([
yt_dlp_path,
"-U",
], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, text=True)
print("✔ yt-dlp is up to date.")
except subprocess.CalledProcessError:
print("⚠ Could not update yt-dlp: Internet unavailable or cannot reach update server")
def main(config_path: str = "yt-playlist-config.json"):
cfg = ConfigLoader(config_path)
if not is_docker():
update_yt_dlp(cfg.yt_dlp_path)
manager = PlaylistManager(cfg)
manager.run()