This commit is contained in:
deathbybandaid 2023-01-06 12:08:25 -05:00
parent 735fab68fc
commit ff0875ac1b

View File

@ -1,9 +1,9 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os import os
# from sys import argv from sys import argv
"""
# title = show title # title = show title
# season = season # # season = season #
# fileNameBase is file name without path # fileNameBase is file name without path
@ -13,6 +13,23 @@ import os
# payload = {"data": {"scanConfig": { "dbID": dbName, "arrayOrPath": ["/media/TVShows/" + title + "/Season " + season + "/" + fileNameBase[:-3] + '.mkv'], "mode": "scanFolderWatcher"}}} # payload = {"data": {"scanConfig": { "dbID": dbName, "arrayOrPath": ["/media/TVShows/" + title + "/Season " + season + "/" + fileNameBase[:-3] + '.mkv'], "mode": "scanFolderWatcher"}}}
# headers = {"content-type": "application/json"} # headers = {"content-type": "application/json"}
# response = requests.post(tdarr_url, json=payload, headers=headers) # 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"
}
}
}
"""
# fp = open('/opt/testlog.log', 'a', 0) # fp = open('/opt/testlog.log', 'a', 0)
@ -22,22 +39,24 @@ import os
def main(): def main():
SCRIPT_PATH = os.path.realpath(__file__) SCRIPT_PATH = os.path.realpath(__file__)
SCRIPT_DIR = os.path.dirname(SCRIPT_PATH) SCRIPT_DIR = os.path.dirname(SCRIPT_PATH)
ENV_FILE = f"{SCRIPT_DIR}\\ARR_ENV.txt" # ENV_FILE = f"{SCRIPT_DIR}\\ARR_ENV.txt"
envs = {} print("argv %s" % argv)
# envs = {}
# Checking all potentiall environment variables # Checking all potentiall environment variables
with open(ENV_FILE, 'r') as f: # with open(ENV_FILE, 'r') as f:
for line in f: # for line in f:
env = line.rstrip() # env = line.rstrip()
if env in os.environ: # if env in os.environ:
envs[env] = os.environ[env] # envs[env] = os.environ[env]
# No environment variables were found # # No environment variables were found
# Either the script was run manually as a test (ie Not ran by *arr) # # Either the script was run manually as a test (ie Not ran by *arr)
# or, something went wrong : ) # # or, something went wrong : )
if len(envs) == 0: # if len(envs) == 0:
raise Exception('No *arr Environment variables were found.') # raise Exception('No *arr Environment variables were found.')
# envs is now a dictionary containing any *arr variables found # envs is now a dictionary containing any *arr variables found
# Call your own script here, or do what you want with the environment variables found # Call your own script here, or do what you want with the environment variables found