From 20dad86fc3f3c0f31e25dd47d8a72340b2e6a294 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 7 Jan 2023 12:11:53 -0500 Subject: [PATCH] test --- tdarr_inform.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tdarr_inform.py b/tdarr_inform.py index dd52851..81e72fd 100644 --- a/tdarr_inform.py +++ b/tdarr_inform.py @@ -26,7 +26,8 @@ expected_paths_env_variables = { }, "radarr": { "Download": ["radarr_moviefile_path", "radarr_deletedpaths"], - "Rename": ["radarr_moviefile_paths", "radarr_moviefile_previouspaths"] + "Rename": ["radarr_moviefile_paths", "radarr_moviefile_previouspaths"], + "MovieDelete": ["radarr_moviefile_paths", "radarr_moviefile_previouspaths"] }, } @@ -34,11 +35,11 @@ expected_paths_env_variables = { def loggit(logtext, force_err=False): if script_settings["logging"]["log_file"]: with open(script_settings["logging"]["log_file_path"], 'a') as logwrite: - logwrite.write(logtext) + logwrite.write("%s\n" % logtext) if script_settings["logging"]["output_level"] or force_err: - sys.stderr.write(logtext) + sys.stderr.write("%s\n" % logtext) else: - sys.stdout.write(logtext) + sys.stdout.write("%s\n" % logtext) def do_tdarr_inform(dbID, file_paths): @@ -53,7 +54,7 @@ def do_tdarr_inform(dbID, file_paths): } } response = requests.post("%s/api/v2/scan-files" % script_settings["tdarr"]["url"], json=payload, headers=headers) - loggit("Tdarr response: %s\n" % response.text) + loggit("Tdarr response: %s" % response.text) def do_file_search(arr_file_path): @@ -98,7 +99,7 @@ def get_file_path_list(arr): invalid_keys = [x for x in file_path_env_list if x not in os.environ] if len(invalid_keys): for x in invalid_keys: - loggit("%s Environment variable was missing.\n" % x) + loggit("%s Environment variable was missing." % x) sys.exit(1) env_paths = [] @@ -137,7 +138,7 @@ def main(): # What event_type was recieved arr["event_type"] = os.environ["%s_eventtype" % arr["type"]] - loggit("tdarr_inform Recieved %s Event from %s\n" % (arr["event_type"], arr["type"])) + loggit("tdarr_inform Recieved %s Event from %s" % (arr["event_type"], arr["type"])) # Gracefuilly exit a Test Event if arr["event_type"] == "Test": @@ -157,14 +158,14 @@ def main(): # Dedupe dbID/file_path combinations inform_dict = {} for file_path in arr["file_paths"]: - loggit("Event Item: %s\n" % file_path) - loggit("Searching tdarr API for item's library ID\n") + loggit("Event Item: %s" % file_path) + loggit("Searching tdarr API for item's library ID") dbID = do_file_search(file_path) if not dbID: - loggit("No exact match found, searching for library ID from Reverse Recursive Directory matching\n") + loggit("No exact match found, searching for library ID from Reverse Recursive Directory matching") dbID = do_reverse_recursive_directory_search(file_path) if not dbID: - loggit("No match found\n") + loggit("No match found") else: if dbID not in list(inform_dict.keys()): inform_dict[dbID] = [] @@ -172,10 +173,10 @@ def main(): inform_dict[dbID].append(file_path) if not len(inform_dict.keys()): - loggit("No matches found, Exiting\n") + loggit("No matches found, Exiting") sys.exit(1) - loggit("Preparing payload to POST to tdarr API\n") + loggit("Preparing payload to POST to tdarr API") for dbID in list(inform_dict.keys()): do_tdarr_inform(dbID, inform_dict[dbID])