feat: check dependencies installed

master
WorldObservationLog 5 months ago
parent 954cb3c28b
commit 6f2336a693
  1. 8
      src/cmd.py
  2. 10
      src/utils.py

@ -17,7 +17,7 @@ from src.quality import get_available_song_audio_quality
from src.rip import rip_song, rip_album, rip_artist, rip_playlist
from src.types import GlobalAuthParams
from src.url import AppleMusicURL, URLType, Song
from src.utils import get_song_id_from_m3u8
from src.utils import get_song_id_from_m3u8, check_dep
class NewInteractiveShell:
@ -30,6 +30,12 @@ class NewInteractiveShell:
parser: argparse.ArgumentParser
def __init__(self, loop: asyncio.AbstractEventLoop):
dep_installed, missing_dep = check_dep()
if not dep_installed:
logger.error(f"Dependence {missing_dep} was not installed!")
loop.stop()
sys.exit()
self.loop = loop
self.config = Config.load_from_config()
init_client_and_lock(self.config.download.proxy, self.config.download.parallelNum)

@ -1,4 +1,5 @@
import asyncio
import subprocess
import sys
import time
from datetime import datetime, timedelta
@ -206,3 +207,12 @@ def playlist_write_song_index(playlist: PlaylistInfo):
def convent_mac_timestamp_to_datetime(timestamp: int):
d = datetime.strptime("01-01-1904", "%m-%d-%Y")
return d + timedelta(seconds=timestamp)
def check_dep():
for dep in ["ffmpeg", "gpac", "mp4box", "mp4edit", "mp4extract", "adb"]:
try:
subprocess.run(dep, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
except FileNotFoundError:
return False, dep
return True, None

Loading…
Cancel
Save