added a test run #26

pull/35/head
meisnate12 4 years ago
parent 31c66b3c66
commit 1582803da6

@ -411,14 +411,14 @@ class Config:
util.seperator()
def update_libraries(self):
def update_libraries(self, test):
for library in self.libraries:
logger.info("")
util.seperator("{} Library".format(library.name))
try: library.update_metadata(self.TMDb)
try: library.update_metadata(self.TMDb, test)
except Failed as e: logger.error(e)
logger.info("")
util.seperator("{} Library Collections".format(library.name))
util.seperator("{} Library {}Collections".format(library.name, "Test " if test else ""))
collections = library.collections
if collections:
logger.info("")
@ -426,6 +426,8 @@ class Config:
logger.info("")
movie_map, show_map = self.map_guids(library)
for c in collections:
if test and ("test" not in collections[c] or collections[c]["test"] is not True):
continue
try:
logger.info("")
util.seperator("{} Collection".format(c))
@ -556,6 +558,7 @@ class Config:
logger.info("Collection Error: {} skipped. MyAnimeList must be configured".format(m))
map = {}
elif collections[c][m] is not None:
logger.debug("")
logger.debug("Method: {}".format(m))
logger.debug("Value: {}".format(collections[c][m]))
if m in util.method_alias:
@ -851,7 +854,7 @@ class Config:
else:
methods.append((method_name, values))
elif method_name in util.all_lists: methods.append((method_name, util.get_list(collections[c][m])))
elif method_name not in ["sync_mode", "schedule", "tmdb_person"]: logger.error("Collection Error: {} attribute not supported".format(method_name))
elif method_name not in util.other_attributes: logger.error("Collection Error: {} attribute not supported".format(method_name))
else:
logger.error("Collection Error: {} attribute is blank".format(m))
except Failed as e:
@ -868,16 +871,15 @@ class Config:
if library.Sonarr:
do_arr = details["add_to_arr"] if "add_to_arr" in details else library.Sonarr.add
items_found = 0
library.clear_collection_missing(collection_name)
for method, values in methods:
logger.debug("")
logger.debug("Method: {}".format(method))
logger.debug("Values: {}".format(values))
pretty = util.pretty_names[method] if method in util.pretty_names else method
for value in values:
logger.debug("Value: {}".format(value))
items = []
missing_movies = []
missing_shows = []
@ -896,6 +898,7 @@ class Config:
else: missing_shows.append(show_id)
return items_found_inside
logger.info("")
logger.debug("Value: {}".format(value))
if method == "plex_all":
logger.info("Processing {} {}".format(pretty, "Movies" if library.is_movie else "Shows"))
items = library.Plex.all()

@ -171,7 +171,9 @@ class PlexAPI:
length = 0
for i, item in enumerate(items, 1):
try: current = self.fetchItem(item.ratingKey if isinstance(item, (Movie, Show)) else int(item))
except BadRequest: raise Failed("Plex Error: Item {} not found".format(item))
except (BadRequest, NotFound):
logger.error("Plex Error: Item {} not found".format(item))
continue
match = True
if filters:
length = util.print_return(length, "Filtering {}/{} {}".format((" " * (max_length - len(str(i)))) + str(i), total, current.title))
@ -241,13 +243,15 @@ class PlexAPI:
def search_item(self, data, year=None):
return util.choose_from_list(self.search(data, year=year), "movie" if self.is_movie else "show", str(data), exact=True)
def update_metadata(self, TMDb):
def update_metadata(self, TMDb, test):
logger.info("")
util.seperator("{} Library Metadata".format(self.name))
logger.info("")
if not self.metadata:
raise Failed("No metadata to edit")
for m in self.metadata:
if test and ("test" not in self.metadata[m] or self.metadata[m]["test"] is not True):
continue
logger.info("")
util.seperator()
logger.info("")

@ -251,6 +251,12 @@ collectionless_lists = [
"url_background", "file_background",
"name_mapping"
]
other_attributes = [
"schedule",
"sync_mode",
"test",
"tmdb_person"
]
dictionary_lists = [
"filters",
"mal_season",

@ -3,10 +3,11 @@ from modules import tests, util
from modules.config import Config
parser = argparse.ArgumentParser()
parser.add_argument("--test", dest="test", help=argparse.SUPPRESS, action="store_true", default=False)
parser.add_argument("--mytests", dest="tests", 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("-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("-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 only tests without the scheduler", action="store_true", default=False)
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)
args = parser.parse_args()
@ -41,7 +42,7 @@ file_handler.setFormatter(logging.Formatter("[%(asctime)s] %(filename)-27s %(lev
cmd_handler = logging.StreamHandler()
cmd_handler.setFormatter(logging.Formatter("| %(message)-100s |"))
cmd_handler.setLevel(logging.INFO)
cmd_handler.setLevel(logging.DEBUG if args.tests or args.test else logging.INFO)
logger.addHandler(cmd_handler)
logger.addHandler(file_handler)
@ -59,27 +60,30 @@ logger.info(util.get_centered_text("
logger.info(util.get_centered_text(" Version: 1.1.0 "))
util.seperator()
if args.test:
if args.tests:
tests.run_tests(default_dir)
sys.exit(0)
def start(config_path):
def start(config_path, test, daily):
if daily: type = "Daily "
elif test: type = "Test "
else: type = ""
util.seperator("Starting {}Run".format(type))
try:
util.seperator("Starting Daily Run")
config = Config(default_dir, config_path)
config.update_libraries()
config.update_libraries(test)
except Exception as e:
util.print_stacktrace()
logger.critical(e)
logger.info("")
util.seperator("Finished Daily Run")
util.seperator("Finished {}Run".format(type))
try:
if args.run:
start(args.config)
if args.run or args.test:
start(args.config, args.test, False)
else:
length = 0
schedule.every().day.at(args.time).do(start, args.config)
schedule.every().day.at(args.time).do(start, args.config, False, True)
while True:
schedule.run_pending()
current = datetime.datetime.now().strftime("%H:%M")

Loading…
Cancel
Save