mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2025-02-16 22:08:25 +00:00
added --libraries as a command line input
This commit is contained in:
parent
f34c589f3b
commit
51aaa94722
2 changed files with 13 additions and 7 deletions
|
@ -50,7 +50,7 @@ mass_genre_update_options = {"tmdb": "Use TMDb Metadata", "omdb": "Use IMDb Meta
|
||||||
library_types = {"movie": "For Movie Libraries", "show": "For Show Libraries"}
|
library_types = {"movie": "For Movie Libraries", "show": "For Show Libraries"}
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
def __init__(self, default_dir, config_path=None):
|
def __init__(self, default_dir, config_path=None, libraries_to_run=None):
|
||||||
logger.info("Locating config...")
|
logger.info("Locating config...")
|
||||||
if config_path and os.path.exists(config_path): self.config_path = os.path.abspath(config_path)
|
if config_path and os.path.exists(config_path): self.config_path = os.path.abspath(config_path)
|
||||||
elif config_path and not os.path.exists(config_path): raise Failed(f"Config Error: config not found at {os.path.abspath(config_path)}")
|
elif config_path and not os.path.exists(config_path): raise Failed(f"Config Error: config not found at {os.path.abspath(config_path)}")
|
||||||
|
@ -311,7 +311,10 @@ class Config:
|
||||||
self.libraries = []
|
self.libraries = []
|
||||||
try: libs = check_for_attribute(self.data, "libraries", throw=True)
|
try: libs = check_for_attribute(self.data, "libraries", throw=True)
|
||||||
except Failed as e: raise Failed(e)
|
except Failed as e: raise Failed(e)
|
||||||
|
requested_libraries = util.get_list(libraries_to_run) if libraries_to_run else None
|
||||||
for library_name, lib in libs.items():
|
for library_name, lib in libs.items():
|
||||||
|
if requested_libraries and library_name not in requested_libraries:
|
||||||
|
continue
|
||||||
util.separator()
|
util.separator()
|
||||||
params = {}
|
params = {}
|
||||||
logger.info("")
|
logger.info("")
|
||||||
|
|
|
@ -10,13 +10,14 @@ except ModuleNotFoundError:
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("--my-tests", dest="tests", help=argparse.SUPPRESS, action="store_true", default=False)
|
parser.add_argument("--my-tests", dest="tests", help=argparse.SUPPRESS, action="store_true", default=False)
|
||||||
parser.add_argument("--debug", dest="debug", help=argparse.SUPPRESS, action="store_true", default=False)
|
parser.add_argument("-db", "--debug", dest="debug", help=argparse.SUPPRESS, action="store_true", default=False)
|
||||||
parser.add_argument("-c", "--config", dest="config", help="Run with desired *.yml file", type=str)
|
parser.add_argument("-c", "--config", dest="config", help="Run with desired *.yml file", type=str)
|
||||||
parser.add_argument("-t", "--time", dest="time", help="Time to update each day use format HH:MM (Default: 03:00)", default="03:00", type=str)
|
parser.add_argument("-t", "--time", dest="time", help="Time to update each day use format HH:MM (Default: 03:00)", default="03:00", type=str)
|
||||||
parser.add_argument("-re", "--resume", dest="resume", help="Resume collection run from a specific collection", type=str)
|
parser.add_argument("-re", "--resume", dest="resume", help="Resume collection run from a specific collection", type=str)
|
||||||
parser.add_argument("-r", "--run", dest="run", help="Run without the scheduler", action="store_true", default=False)
|
parser.add_argument("-r", "--run", dest="run", help="Run without the scheduler", action="store_true", default=False)
|
||||||
parser.add_argument("-rt", "--test", "--tests", "--run-test", "--run-tests", dest="test", help="Run in debug mode with only collections that have test: true", action="store_true", default=False)
|
parser.add_argument("-rt", "--test", "--tests", "--run-test", "--run-tests", dest="test", help="Run in debug mode with only collections that have test: true", action="store_true", default=False)
|
||||||
parser.add_argument("-cl", "--collection", "--collections", dest="collections", help="Process only specified collections (comma-separated list)", type=str)
|
parser.add_argument("-cl", "--collection", "--collections", dest="collections", help="Process only specified collections (comma-separated list)", type=str)
|
||||||
|
parser.add_argument("-l", "--library", "--libraries", dest="libraries", help="Process only specified libraries (comma-separated list)", type=str)
|
||||||
parser.add_argument("-d", "--divider", dest="divider", help="Character that divides the sections (Default: '=')", default="=", type=str)
|
parser.add_argument("-d", "--divider", dest="divider", help="Character that divides the sections (Default: '=')", default="=", type=str)
|
||||||
parser.add_argument("-w", "--width", dest="width", help="Screen Width (Default: 100)", default=100, type=int)
|
parser.add_argument("-w", "--width", dest="width", help="Screen Width (Default: 100)", default=100, type=int)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -38,6 +39,7 @@ test = check_bool("PMM_TEST", args.test)
|
||||||
debug = check_bool("PMM_DEBUG", args.debug)
|
debug = check_bool("PMM_DEBUG", args.debug)
|
||||||
run = check_bool("PMM_RUN", args.run)
|
run = check_bool("PMM_RUN", args.run)
|
||||||
collections = os.environ.get("PMM_COLLECTIONS") if os.environ.get("PMM_COLLECTIONS") else args.collections
|
collections = os.environ.get("PMM_COLLECTIONS") if os.environ.get("PMM_COLLECTIONS") else args.collections
|
||||||
|
libraries = os.environ.get("PMM_LIBRARIES") if os.environ.get("PMM_LIBRARIES") else args.libraries
|
||||||
resume = os.environ.get("PMM_RESUME") if os.environ.get("PMM_RESUME") else args.resume
|
resume = os.environ.get("PMM_RESUME") if os.environ.get("PMM_RESUME") else args.resume
|
||||||
|
|
||||||
time_to_run = os.environ.get("PMM_TIME") if os.environ.get("PMM_TIME") else args.time
|
time_to_run = os.environ.get("PMM_TIME") if os.environ.get("PMM_TIME") else args.time
|
||||||
|
@ -96,15 +98,16 @@ if my_tests:
|
||||||
tests.run_tests(default_dir)
|
tests.run_tests(default_dir)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def start(config_path, is_test, daily, collections_to_run, resume_from):
|
def start(config_path, is_test, daily, collections_to_run, libraries_to_run, resume_from):
|
||||||
if daily: start_type = "Daily "
|
if daily: start_type = "Daily "
|
||||||
elif is_test: start_type = "Test "
|
elif is_test: start_type = "Test "
|
||||||
elif collections_to_run: start_type = "Collections "
|
elif collections_to_run: start_type = "Collections "
|
||||||
|
elif libraries_to_run: start_type = "Libraries "
|
||||||
else: start_type = ""
|
else: start_type = ""
|
||||||
start_time = datetime.now()
|
start_time = datetime.now()
|
||||||
util.separator(f"Starting {start_type}Run")
|
util.separator(f"Starting {start_type}Run")
|
||||||
try:
|
try:
|
||||||
config = Config(default_dir, config_path)
|
config = Config(default_dir, config_path, libraries_to_run)
|
||||||
config.update_libraries(is_test, collections_to_run, resume_from)
|
config.update_libraries(is_test, collections_to_run, resume_from)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
util.print_stacktrace()
|
util.print_stacktrace()
|
||||||
|
@ -113,11 +116,11 @@ def start(config_path, is_test, daily, collections_to_run, resume_from):
|
||||||
util.separator(f"Finished {start_type}Run\nRun Time: {str(datetime.now() - start_time).split('.')[0]}")
|
util.separator(f"Finished {start_type}Run\nRun Time: {str(datetime.now() - start_time).split('.')[0]}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if run or test or collections or resume:
|
if run or test or collections or libraries or resume:
|
||||||
start(config_file, test, False, collections, resume)
|
start(config_file, test, False, collections, libraries, resume)
|
||||||
else:
|
else:
|
||||||
length = 0
|
length = 0
|
||||||
schedule.every().day.at(time_to_run).do(start, config_file, False, True, None, None)
|
schedule.every().day.at(time_to_run).do(start, config_file, False, True, None, None, None)
|
||||||
while True:
|
while True:
|
||||||
schedule.run_pending()
|
schedule.run_pending()
|
||||||
current = datetime.now().strftime("%H:%M")
|
current = datetime.now().strftime("%H:%M")
|
||||||
|
|
Loading…
Add table
Reference in a new issue