Add debug_level option

pull/14/head
Luigi311 2022-06-13 18:16:55 -06:00
parent 4657097f6d
commit c18f0a2582
3 changed files with 9 additions and 4 deletions

View File

@ -2,6 +2,8 @@
DRYRUN = "True"
## Additional logging information
DEBUG = "True"
## Debugging level, INFO is default, DEBUG is more verbose
DEBUG_LEVEL = "INFO"
## How often to run the script in seconds
SLEEP_DURATION = "3600"
## Log file where all output will be written to

View File

@ -46,7 +46,7 @@ def cleanup_watched(watched_list_1, watched_list_2, user_mapping=None, library_m
for watch_list_2_item_key, watch_list_2_item_value in watch_list_2_item.items():
if watch_list_1_key == watch_list_2_item_key and watch_list_1_value == watch_list_2_item_value:
if item in modified_watched_list_1[user_1][library_1]:
logger(f"Removing {item} from {library_1}", 1)
logger(f"Removing {item} from {library_1}", 3)
modified_watched_list_1[user_1][library_1].remove(item)
@ -64,13 +64,13 @@ def cleanup_watched(watched_list_1, watched_list_2, user_mapping=None, library_m
if episode_key in episode_watched_list_2_keys_dict.keys():
if episode_item in episode_watched_list_2_keys_dict[episode_key]:
if episode in modified_watched_list_1[user_1][library_1][show_key_1][season]:
logger(f"Removing {show_key_dict['title']} {episode} from {library_1}", 1)
logger(f"Removing {show_key_dict['title']} {episode} from {library_1}", 3)
modified_watched_list_1[user_1][library_1][show_key_1][season].remove(episode)
# Remove empty seasons
if len(modified_watched_list_1[user_1][library_1][show_key_1][season]) == 0:
if season in modified_watched_list_1[user_1][library_1][show_key_1]:
logger(f"Removing {season} from {library_1} because it is empty", 1)
logger(f"Removing {season} from {library_1} because it is empty", 3)
del modified_watched_list_1[user_1][library_1][show_key_1][season]
# If the show is empty, remove the show

View File

@ -6,14 +6,17 @@ logfile = os.getenv("LOGFILE","log.log")
def logger(message, log_type=0):
debug = str_to_bool(os.getenv("DEBUG", "True"))
debug_level = os.getenv("DEBUG_LEVEL", "INFO")
output = str(message)
if log_type == 0:
pass
elif log_type == 1 and debug:
elif log_type == 1 and (debug or debug_level == "INFO"):
output = f"[INFO]: {output}"
elif log_type == 2:
output = f"[ERROR]: {output}"
elif log_type == 3 and (debug and debug_level == "DEBUG"):
output = f"[DEBUG]: {output}"
else:
output = None