From 8a34139b93c2e0dc76508063e7bf2e904eef7472 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 6 Jan 2023 19:55:46 -0500 Subject: [PATCH] test --- tdarr_inform.py | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/tdarr_inform.py b/tdarr_inform.py index 9d8383d..5859a2d 100644 --- a/tdarr_inform.py +++ b/tdarr_inform.py @@ -10,7 +10,6 @@ SCRIPT_DIR = os.path.dirname(SCRIPT_PATH) script_settings = { "tdarr": { "url": "http://tdarr-server1.ipa.dbb:8265", - "dbID": "fGxwT-ws7" }, "logging": { "log_file": True, @@ -64,25 +63,23 @@ def do_file_search(arr_file_path): return None if not len(response_json): return None - DBids = [x["DB"] for x in response_json if "DB" in list(x.keys())] - DBids = list(set(DBids)) - if len(DBids) > 1: + dbIDs = [x["DB"] for x in response_json if "DB" in list(x.keys())] + dbIDs = list(set(dbIDs)) + if len(dbIDs) > 1: return None - return DBids[0] + return dbIDs[0] def do_reverse_recursive_directory_search(arr_file_path): - DBid = None + dbID = None arr_dir_path = os.path.dirname(arr_file_path) - print(arr_dir_path) + print(os.path.abspath(os.sep)) while arr_dir_path != "/": arr_dir_path = os.path.dirname(arr_dir_path) - print(arr_dir_path) - DBid = do_file_search(arr_dir_path) - if DBid: + dbID = do_file_search(arr_dir_path) + if dbID: break - print(DBid) - return DBid + return dbID def main(): @@ -124,25 +121,20 @@ def main(): # loggit("%s Environment variable was missing." % arr_file_path_key, True) # sys.exit(1) # arr_file_path = os.environ[arr_file_path_key] - arr_file_path = "/Drivepool/Media/TV/fCartoons/Ben 10 (2016)/Season 2/Ben 10 (2016) - S02E31 - Chicken Nuggets of Wisdom.mkv" + arr_file_path = "/Drivepool/Media/TV/Cartoons/Ben 10 (2016)/Season 2/Ben 10 (2016) - S02E31 - Chicken Nuggets of Wisdom.mkv" loggit("Event Item: %s\n" % arr_file_path) - # loggit("Preparing payload to POST to tdarr API\n") - loggit("Searching tdarr API for item's library ID\n") - """ - DBid = do_file_search(arr_file_path) - if not DBid: + dbID = do_file_search(arr_file_path) + if not dbID: loggit("No exact match found, searching for library ID from Reverse Recursive Directory matching\n") - else: - print(DBid) - """ - DBid = do_reverse_recursive_directory_search(arr_file_path) - if not DBid: - loggit("No match found\n") - sys.exit(0) - else: - print(DBid) + dbID = do_reverse_recursive_directory_search(arr_file_path) + if not dbID: + loggit("No match found\n") + sys.exit(0) + + loggit("Preparing payload to POST to tdarr API\n") + # do_tdarr_inform(dbID, arr_file_path) if __name__ == "__main__":