test
This commit is contained in:
parent
d2617d13cc
commit
66ee28229f
@ -4,20 +4,29 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
tdarr_settings = {
|
script_settings = {
|
||||||
"url": "http://tdarr-server1.ipa.dbb:8265/api/v2/scan-files",
|
"tdarr": {
|
||||||
"dbID": "fGxwT-ws7"
|
"url": "http://tdarr-server1.ipa.dbb:8265/api/v2/scan-files",
|
||||||
}
|
"dbID": "fGxwT-ws7"
|
||||||
|
},
|
||||||
|
"logging": {
|
||||||
|
"logfile": True,
|
||||||
|
"output_level": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def loggit(logtext):
|
def loggit(logtext):
|
||||||
SCRIPT_PATH = os.path.realpath(__file__)
|
if script_settings["logging"]["logfile"]:
|
||||||
SCRIPT_DIR = os.path.dirname(SCRIPT_PATH)
|
SCRIPT_PATH = os.path.realpath(__file__)
|
||||||
log_file = os.path.join(SCRIPT_DIR, "testlog.log")
|
SCRIPT_DIR = os.path.dirname(SCRIPT_PATH)
|
||||||
with open(log_file, 'a') as logwrite:
|
log_file = os.path.join(SCRIPT_DIR, "testlog.log")
|
||||||
logwrite.write(logtext)
|
with open(log_file, 'a') as logwrite:
|
||||||
sys.stdout.write(logtext)
|
logwrite.write(logtext)
|
||||||
sys.stderr.write(logtext)
|
if script_settings["logging"]["output"]:
|
||||||
|
sys.stderr.write(logtext)
|
||||||
|
else:
|
||||||
|
sys.stdout.write(logtext)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -48,7 +57,7 @@ def main():
|
|||||||
payload = {
|
payload = {
|
||||||
"data": {
|
"data": {
|
||||||
"scanConfig": {
|
"scanConfig": {
|
||||||
"dbID": tdarr_settings["dbID"],
|
"dbID": script_settings["tdarr"]["dbID"],
|
||||||
"arrayOrPath": [
|
"arrayOrPath": [
|
||||||
arr_file_path
|
arr_file_path
|
||||||
],
|
],
|
||||||
@ -57,7 +66,7 @@ def main():
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
headers = {"content-type": "application/json"}
|
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)
|
loggit("Tdarr response: %s\n" % response)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user