This commit is contained in:
deathbybandaid 2023-01-06 13:51:51 -05:00
parent d2617d13cc
commit 66ee28229f

View File

@ -4,20 +4,29 @@ import os
import sys
import requests
tdarr_settings = {
script_settings = {
"tdarr": {
"url": "http://tdarr-server1.ipa.dbb:8265/api/v2/scan-files",
"dbID": "fGxwT-ws7"
},
"logging": {
"logfile": True,
"output_level": 1
}
}
def loggit(logtext):
if script_settings["logging"]["logfile"]:
SCRIPT_PATH = os.path.realpath(__file__)
SCRIPT_DIR = os.path.dirname(SCRIPT_PATH)
log_file = os.path.join(SCRIPT_DIR, "testlog.log")
with open(log_file, 'a') as logwrite:
logwrite.write(logtext)
sys.stdout.write(logtext)
if script_settings["logging"]["output"]:
sys.stderr.write(logtext)
else:
sys.stdout.write(logtext)
def main():
@ -48,7 +57,7 @@ def main():
payload = {
"data": {
"scanConfig": {
"dbID": tdarr_settings["dbID"],
"dbID": script_settings["tdarr"]["dbID"],
"arrayOrPath": [
arr_file_path
],
@ -57,7 +66,7 @@ def main():
}
}
headers = {"content-type": "application/json"}
response = requests.post(tdarr_settings["url"], json=payload, headers=headers)
response = requests.post(script_settings["tdarr"]["url"], json=payload, headers=headers)
loggit("Tdarr response: %s\n" % response)