Add debug_level option
parent
4657097f6d
commit
c18f0a2582
|
|
@ -2,6 +2,8 @@
|
||||||
DRYRUN = "True"
|
DRYRUN = "True"
|
||||||
## Additional logging information
|
## Additional logging information
|
||||||
DEBUG = "True"
|
DEBUG = "True"
|
||||||
|
## Debugging level, INFO is default, DEBUG is more verbose
|
||||||
|
DEBUG_LEVEL = "INFO"
|
||||||
## How often to run the script in seconds
|
## How often to run the script in seconds
|
||||||
SLEEP_DURATION = "3600"
|
SLEEP_DURATION = "3600"
|
||||||
## Log file where all output will be written to
|
## Log file where all output will be written to
|
||||||
|
|
|
||||||
6
main.py
6
main.py
|
|
@ -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():
|
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 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]:
|
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)
|
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_key in episode_watched_list_2_keys_dict.keys():
|
||||||
if episode_item in episode_watched_list_2_keys_dict[episode_key]:
|
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]:
|
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)
|
modified_watched_list_1[user_1][library_1][show_key_1][season].remove(episode)
|
||||||
|
|
||||||
# Remove empty seasons
|
# Remove empty seasons
|
||||||
if len(modified_watched_list_1[user_1][library_1][show_key_1][season]) == 0:
|
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]:
|
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]
|
del modified_watched_list_1[user_1][library_1][show_key_1][season]
|
||||||
|
|
||||||
# If the show is empty, remove the show
|
# If the show is empty, remove the show
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,17 @@ logfile = os.getenv("LOGFILE","log.log")
|
||||||
|
|
||||||
def logger(message, log_type=0):
|
def logger(message, log_type=0):
|
||||||
debug = str_to_bool(os.getenv("DEBUG", "True"))
|
debug = str_to_bool(os.getenv("DEBUG", "True"))
|
||||||
|
debug_level = os.getenv("DEBUG_LEVEL", "INFO")
|
||||||
|
|
||||||
output = str(message)
|
output = str(message)
|
||||||
if log_type == 0:
|
if log_type == 0:
|
||||||
pass
|
pass
|
||||||
elif log_type == 1 and debug:
|
elif log_type == 1 and (debug or debug_level == "INFO"):
|
||||||
output = f"[INFO]: {output}"
|
output = f"[INFO]: {output}"
|
||||||
elif log_type == 2:
|
elif log_type == 2:
|
||||||
output = f"[ERROR]: {output}"
|
output = f"[ERROR]: {output}"
|
||||||
|
elif log_type == 3 and (debug and debug_level == "DEBUG"):
|
||||||
|
output = f"[DEBUG]: {output}"
|
||||||
else:
|
else:
|
||||||
output = None
|
output = None
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue