added a test run #26

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

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

@ -171,7 +171,9 @@ class PlexAPI:
length = 0 length = 0
for i, item in enumerate(items, 1): for i, item in enumerate(items, 1):
try: current = self.fetchItem(item.ratingKey if isinstance(item, (Movie, Show)) else int(item)) 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 match = True
if filters: if filters:
length = util.print_return(length, "Filtering {}/{} {}".format((" " * (max_length - len(str(i)))) + str(i), total, current.title)) 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): 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) 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("") logger.info("")
util.seperator("{} Library Metadata".format(self.name)) util.seperator("{} Library Metadata".format(self.name))
logger.info("") logger.info("")
if not self.metadata: if not self.metadata:
raise Failed("No metadata to edit") raise Failed("No metadata to edit")
for m in self.metadata: 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("") logger.info("")
util.seperator() util.seperator()
logger.info("") logger.info("")

@ -251,6 +251,12 @@ collectionless_lists = [
"url_background", "file_background", "url_background", "file_background",
"name_mapping" "name_mapping"
] ]
other_attributes = [
"schedule",
"sync_mode",
"test",
"tmdb_person"
]
dictionary_lists = [ dictionary_lists = [
"filters", "filters",
"mal_season", "mal_season",
@ -374,7 +380,7 @@ movie_only_filters = [
"audio_language", "audio_language.not", "audio_language", "audio_language.not",
"country", "country.not", "country", "country.not",
"director", "director.not", "director", "director.not",
"original_language", "original_language.not", "original_language", "original_language.not",
"subtitle_language", "subtitle_language.not", "subtitle_language", "subtitle_language.not",
"video_resolution", "video_resolution.not", "video_resolution", "video_resolution.not",
"writer", "writer.not" "writer", "writer.not"

@ -3,10 +3,11 @@ from modules import tests, util
from modules.config import Config from modules.config import Config
parser = argparse.ArgumentParser() 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("-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("-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 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("-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()
@ -41,7 +42,7 @@ file_handler.setFormatter(logging.Formatter("[%(asctime)s] %(filename)-27s %(lev
cmd_handler = logging.StreamHandler() cmd_handler = logging.StreamHandler()
cmd_handler.setFormatter(logging.Formatter("| %(message)-100s |")) 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(cmd_handler)
logger.addHandler(file_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 ")) logger.info(util.get_centered_text(" Version: 1.1.0 "))
util.seperator() util.seperator()
if args.test: if args.tests:
tests.run_tests(default_dir) tests.run_tests(default_dir)
sys.exit(0) 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: try:
util.seperator("Starting Daily Run")
config = Config(default_dir, config_path) config = Config(default_dir, config_path)
config.update_libraries() config.update_libraries(test)
except Exception as e: except Exception as e:
util.print_stacktrace() util.print_stacktrace()
logger.critical(e) logger.critical(e)
logger.info("") logger.info("")
util.seperator("Finished Daily Run") util.seperator("Finished {}Run".format(type))
try: try:
if args.run: if args.run or args.test:
start(args.config) start(args.config, args.test, False)
else: else:
length = 0 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: while True:
schedule.run_pending() schedule.run_pending()
current = datetime.datetime.now().strftime("%H:%M") current = datetime.datetime.now().strftime("%H:%M")

Loading…
Cancel
Save