diff --git a/env_radarr b/env_radarr deleted file mode 100644 index e69de29..0000000 diff --git a/env_sonarr b/env_sonarr deleted file mode 100644 index e69de29..0000000 diff --git a/tdarr_inform.py b/tdarr_inform.py index cf2ab18..ae50068 100644 --- a/tdarr_inform.py +++ b/tdarr_inform.py @@ -32,10 +32,6 @@ import sys """ -# fp = open('/opt/testlog.log', 'a', 0) -# fp.write("Testing") -# fp.write("%s" % argv) - def main(): SCRIPT_PATH = os.path.realpath(__file__) SCRIPT_DIR = os.path.dirname(SCRIPT_PATH) @@ -43,34 +39,25 @@ def main(): log_file = os.path.join(SCRIPT_DIR, "testlog.log") logwrite = open(log_file, 'a') - envs = {} - if "sonarr_eventtype" in os.environ: arr_type = "sonarr" + arr_event_type = os.environ["sonarr_eventtype"] + arr_file_path_key = "sonarr_episodefile_path" elif "radarr_eventtype" in os.environ: arr_type = "radarr" - envs["%s_eventtype" % arr_type] = os.environ["%s_eventtype" % arr_type] - logwrite.write("Recieved %s Event from %s\n" % (envs["%s_eventtype" % arr_type], arr_type.upper())) + arr_event_type = os.environ["radarr_eventtype"] + arr_file_path_key = "radarr_moviefile_path" - if envs["%s_eventtype" % arr_type] == "Test": + print("tdarr_inform Recieved %s Event from %s\n" % (arr_event_type, arr_type)) + + if arr_event_type == "Test": sys.exit(0) - ENV_FILE = os.path.join(SCRIPT_DIR, "env_%s" % arr_type) - logwrite.write("%s\n" % ENV_FILE) + if arr_event_type not in ["Test"]: + raise Exception("%s is not a supported tdarr_inform Event." % arr_event_type) - # Checking all potentiall environment variables - with open(ENV_FILE, 'r') as f: - for line in f: - env = line.rstrip() - if env in os.environ: - envs[env] = os.environ[env] - logwrite.write("%s %s" % (env, envs[env])) - - # No environment variables were found - # Either the script was run manually as a test (ie Not ran by *arr) - # or, something went wrong : ) - # if len(envs) == 0: - # raise Exception('No *arr Environment variables were found.') + if arr_file_path_key not in os.environ: + raise Exception("%s Environment variable was missing." % arr_file_path_key) logwrite.close()