67 lines
1.8 KiB
Python
67 lines
1.8 KiB
Python
#!/usr/bin/python3
|
|
|
|
import os
|
|
import sys
|
|
|
|
"""
|
|
# title = show title
|
|
# season = season #
|
|
# 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)
|
|
"""
|
|
|
|
"""
|
|
{
|
|
"data": {
|
|
"scanConfig": {
|
|
"dbID": "KX7zfikAc",
|
|
"arrayOrPath": [
|
|
"/data/shows/file1.mp4",
|
|
"/data/shows/file2.mp4",
|
|
"/data/shows/file3.mp4",
|
|
],
|
|
"mode": "scanFolderWatcher"
|
|
}
|
|
}
|
|
}
|
|
"""
|
|
|
|
|
|
def main():
|
|
SCRIPT_PATH = os.path.realpath(__file__)
|
|
SCRIPT_DIR = os.path.dirname(SCRIPT_PATH)
|
|
|
|
log_file = os.path.join(SCRIPT_DIR, "testlog.log")
|
|
logwrite = open(log_file, 'a')
|
|
|
|
if "sonarr_eventtype" in os.environ:
|
|
arr_type = "sonarr"
|
|
arr_event_type = os.environ["sonarr_eventtype"]
|
|
arr_file_path_key = "sonarr_episodefile_path"
|
|
elif "radarr_eventtype" in os.environ:
|
|
arr_type = "radarr"
|
|
arr_event_type = os.environ["radarr_eventtype"]
|
|
arr_file_path_key = "radarr_moviefile_path"
|
|
|
|
sys.stdout.write("tdarr_inform Recieved %s Event from %s\n" % (arr_event_type, arr_type))
|
|
|
|
if arr_event_type == "Test":
|
|
sys.exit(0)
|
|
|
|
if arr_event_type not in ["Test"]:
|
|
raise Exception("%s is not a supported tdarr_inform Event." % arr_event_type)
|
|
|
|
if arr_file_path_key not in os.environ:
|
|
raise Exception("%s Environment variable was missing." % arr_file_path_key)
|
|
|
|
logwrite.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|