This commit is contained in:
deathbybandaid 2023-01-06 13:46:27 -05:00
parent eb35d96612
commit 43d5bc68ce

View File

@ -2,34 +2,22 @@
import os import os
import sys import sys
import requests
""" tdarr_settings = {
# title = show title "url": "http://tdarr-server1.ipa.dbb:8265/api/v2/scan-files",
# season = season # "dbID": "fGxwT-ws7"
# fileNameBase is file name without path }
# dbName is your tdarr database name
# adjust arrayOrPath to path name of fileNameBase
# tdarr_url = "http://192.168.1.122:8266/api/v2/scan-files"
# payload = {"data": {"scanConfig": { "dbID": dbName, "arrayOrPath": ["/media/TVShows/" + title + "/Season " + season + "/" + fileNameBase[:-3] + '.mkv'], "mode": "scanFolderWatcher"}}}
# headers = {"content-type": "application/json"}
# response = requests.post(tdarr_url, json=payload, headers=headers)
"""
"""
{ def loggit(logtext):
"data": { SCRIPT_PATH = os.path.realpath(__file__)
"scanConfig": { SCRIPT_DIR = os.path.dirname(SCRIPT_PATH)
"dbID": "KX7zfikAc", log_file = os.path.join(SCRIPT_DIR, "testlog.log")
"arrayOrPath": [ with open(log_file, 'a') as logwrite:
"/data/shows/file1.mp4", logwrite.write(logtext)
"/data/shows/file2.mp4", sys.stdout.write(logtext)
"/data/shows/file3.mp4", sys.stderr.write(logtext)
],
"mode": "scanFolderWatcher"
}
}
}
"""
def main(): def main():
@ -43,7 +31,7 @@ def main():
arr_event_type = os.environ["radarr_eventtype"] arr_event_type = os.environ["radarr_eventtype"]
arr_file_path_key = "radarr_moviefile_path" arr_file_path_key = "radarr_moviefile_path"
sys.stdout.write("tdarr_inform Recieved %s Event from %s\n" % (arr_event_type, arr_type)) loggit("tdarr_inform Recieved %s Event from %s\n" % (arr_event_type, arr_type))
if arr_event_type == "Test": if arr_event_type == "Test":
sys.exit(0) sys.exit(0)
@ -53,8 +41,26 @@ def main():
if arr_file_path_key not in os.environ: if arr_file_path_key not in os.environ:
raise Exception("%s Environment variable was missing." % arr_file_path_key) raise Exception("%s Environment variable was missing." % arr_file_path_key)
arr_file_path = os.environ[arr_file_path_key]
sys.stderr.write("%s\n" % sys.argv) loggit("Preparing payload to POST to tdarr API\n" % sys.argv)
headers = {"content-type": "application/json"}
payload = {
"data": {
"scanConfig": {
"dbID": tdarr_settings["dbID"],
"arrayOrPath": [
arr_file_path
],
"mode": "scanFolderWatcher"
}
}
}
response = requests.post(tdarr_settings["url"], json=payload, headers=headers)
loggit("Tdarr response: %s\n" % response)
if __name__ == "__main__": if __name__ == "__main__":