diff --git a/tdarr_inform.py b/tdarr_inform.py index 4659d8f..f1ecdc6 100644 --- a/tdarr_inform.py +++ b/tdarr_inform.py @@ -9,7 +9,7 @@ SCRIPT_DIR = os.path.dirname(SCRIPT_PATH) script_settings = { "tdarr": { - "url": "http://tdarr-server1.ipa.dbb:8265/api/v2/scan-files", + "url": "http://tdarr-server1.ipa.dbb:8265", "dbID": "fGxwT-ws7" }, "logging": { @@ -30,6 +30,22 @@ def loggit(logtext, force_err=False): sys.stdout.write(logtext) +def do_tdarr_inform(dbID, arr_file_path): + headers = {"content-type": "application/json"} + payload = { + "data": { + "scanConfig": { + "dbID": dbID, + "arrayOrPath": [ + arr_file_path + ], + "mode": "scanFolderWatcher" + } + } + } + response = requests.post("%s/api/v2/scan-files" % script_settings["tdarr"]["url"], json=payload, headers=headers) + + def main(): if "sonarr_eventtype" in os.environ: @@ -72,24 +88,19 @@ def main(): arr_file_path = "/Drivepool/Media/TV/Cartoons/Ben 10 (2016)/Season 2/Ben 10 (2016) - S02E31 - Chicken Nuggets of Wisdom.mkv" loggit("Found %s\n" % arr_file_path) - loggit("Preparing payload to POST to tdarr API\n") + # loggit("Preparing payload to POST to tdarr API\n") + + loggit("Searching tdarr API for item's library ID\n") - """ payload = { "data": { - "scanConfig": { - "dbID": script_settings["tdarr"]["dbID"], - "arrayOrPath": [ - arr_file_path - ], - "mode": "scanFolderWatcher" - } + "string": arr_file_path + } } - } - """ - # headers = {"content-type": "application/json"} - # response = requests.post(script_settings["tdarr"]["url"], json=payload, headers=headers) - # loggit("Tdarr response: %s\n" % response) + headers = {"content-type": "application/json"} + response = requests.post("%s/api/v2/search-db" % script_settings["tdarr"]["url"], json=payload, headers=headers) + + loggit("Tdarr response: %s\n" % response.text) if __name__ == "__main__":