Skip to content

Commit

Permalink
Add debug_level option
Browse files Browse the repository at this point in the history
  • Loading branch information
Luigi311 committed Jun 14, 2022
1 parent 4657097 commit c18f0a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@

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

Expand Down

0 comments on commit c18f0a2

Please sign in to comment.