mirror of
https://github.com/darkzoul5/YoutubePlaylistSync.git
synced 2026-09-21 22:12:19 +03:00
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:
@@ -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()
|
||||
Reference in New Issue
Block a user