This commit is contained in:
deathbybandaid 2023-01-06 19:55:46 -05:00
parent ecad77f5e6
commit 8a34139b93

View File

@ -10,7 +10,6 @@ SCRIPT_DIR = os.path.dirname(SCRIPT_PATH)
script_settings = { script_settings = {
"tdarr": { "tdarr": {
"url": "http://tdarr-server1.ipa.dbb:8265", "url": "http://tdarr-server1.ipa.dbb:8265",
"dbID": "fGxwT-ws7"
}, },
"logging": { "logging": {
"log_file": True, "log_file": True,
@ -64,25 +63,23 @@ def do_file_search(arr_file_path):
return None return None
if not len(response_json): if not len(response_json):
return None return None
DBids = [x["DB"] for x in response_json if "DB" in list(x.keys())] dbIDs = [x["DB"] for x in response_json if "DB" in list(x.keys())]
DBids = list(set(DBids)) dbIDs = list(set(dbIDs))
if len(DBids) > 1: if len(dbIDs) > 1:
return None return None
return DBids[0] return dbIDs[0]
def do_reverse_recursive_directory_search(arr_file_path): def do_reverse_recursive_directory_search(arr_file_path):
DBid = None dbID = None
arr_dir_path = os.path.dirname(arr_file_path) arr_dir_path = os.path.dirname(arr_file_path)
print(arr_dir_path) print(os.path.abspath(os.sep))
while arr_dir_path != "/": while arr_dir_path != "/":
arr_dir_path = os.path.dirname(arr_dir_path) arr_dir_path = os.path.dirname(arr_dir_path)
print(arr_dir_path) dbID = do_file_search(arr_dir_path)
DBid = do_file_search(arr_dir_path) if dbID:
if DBid:
break break
print(DBid) return dbID
return DBid
def main(): def main():
@ -124,25 +121,20 @@ def main():
# loggit("%s Environment variable was missing." % arr_file_path_key, True) # loggit("%s Environment variable was missing." % arr_file_path_key, True)
# sys.exit(1) # sys.exit(1)
# arr_file_path = os.environ[arr_file_path_key] # 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("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") loggit("Searching tdarr API for item's library ID\n")
""" dbID = do_file_search(arr_file_path)
DBid = do_file_search(arr_file_path) if not dbID:
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\n")
else: dbID = do_reverse_recursive_directory_search(arr_file_path)
print(DBid) if not dbID:
""" loggit("No match found\n")
DBid = do_reverse_recursive_directory_search(arr_file_path) sys.exit(0)
if not DBid:
loggit("No match found\n") loggit("Preparing payload to POST to tdarr API\n")
sys.exit(0) # do_tdarr_inform(dbID, arr_file_path)
else:
print(DBid)
if __name__ == "__main__": if __name__ == "__main__":