diff --git a/tdarr_inform.py b/tdarr_inform.py index 896fcf9..076631d 100644 --- a/tdarr_inform.py +++ b/tdarr_inform.py @@ -59,9 +59,14 @@ def do_file_search(arr_file_path): response = requests.post("%s/api/v2/search-db" % script_settings["tdarr"]["url"], json=payload, headers=headers) loggit("Tdarr response: %s\n" % response) try: - DBid = response.json()[0]["DB"] + response_json = response.json() except Exception: return None + if not len(response_json): + return None + DBids = [x["DB"] for x in response_json if "DB" in list(response_json[x].keys())] + print(DBids) + DBid = DBids[0] return DBid @@ -73,8 +78,8 @@ def do_reverse_recursive_directory_search(arr_file_path): print(arr_dir_path) DBid = do_file_search(arr_dir_path) if DBid: - break - print(DBid) + # break + print(DBid) return None