-
Notifications
You must be signed in to change notification settings - Fork 0
/
automated_console.py
67 lines (63 loc) · 2.25 KB
/
automated_console.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
"""
Replay Mix+ by soreikomori
https://github.com/soreikomori/ReplayMixPlus
"""
version = "1.3.2"
import importlib.metadata as metadata
import subprocess
import sys
import argparse
import logging_setup
import logging
# LOGGING SETUP
# DEPENDENCY CHECK
def checkDependencies(logger):
"""
Checks if the dependencies are installed.
If not found, it will attempt to install them.
:param logger: The logger object.
"""
logger.info("Checking dependencies...")
try:
metadata.version("ytmusicapi")
except metadata.PackageNotFoundError:
logger.error("ytmusicapi not found. Installing...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "ytmusicapi"])
try:
metadata.version("pylast")
except metadata.PackageNotFoundError:
logger.error("pylast not found. Installing...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "pylast"])
logger.info("Dependencies are installed.")
def initialize():
"""
Automated initialization for ReplayMix+. Checks command line arguments and runs the appropriate function.
"""
# CLI Argument Parsing
parser = argparse.ArgumentParser(description="Automated Console for ReplayMix+")
parser.add_argument("-p", "--playlist", action="store_true", help="Updates the ReplayMix+ Playlist.")
parser.add_argument("-c", "--compendium", action="store_true", help="Updates the Compendium.")
parser.add_argument("-vb", "--verbose", action="store_true", help="Enables verbose logging.")
args = parser.parse_args()
# Logging Setup
verbose = False
if args.verbose:
verbose = True
logging_setup.setup_logger(verbose)
logger = logging.getLogger('rpmplusLogger')
# Initialization
logger.info(f" - - - ReplayMix+ Automated Console {version} - - - ")
logger.info("Checking dependencies...")
checkDependencies(logger)
import generator_engine as gE
import compendium_engine as cE
logger.info("Dependencies are installed.")
if args.compendium:
logger.info("Updating Compendium...")
cE.loadAllPlaylists()
if args.playlist:
logger.info("Updating Playlist...")
gE.recreatePlaylist()
logger.info("Exiting...")
initialize()