From 0d14fd3c0615a154d2cb29e3366f6600afb35da6 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Fri, 7 Feb 2020 22:21:42 +0000 Subject: [PATCH] New --- Community/Tdarr_Plugin_43az_add_to_radarr.js | 113 +++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 Community/Tdarr_Plugin_43az_add_to_radarr.js diff --git a/Community/Tdarr_Plugin_43az_add_to_radarr.js b/Community/Tdarr_Plugin_43az_add_to_radarr.js new file mode 100644 index 0000000..18e28e4 --- /dev/null +++ b/Community/Tdarr_Plugin_43az_add_to_radarr.js @@ -0,0 +1,113 @@ + + + +module.exports.details = function details() { + + return { + id: "Tdarr_Plugin_43az_add_to_radarr", + Stage: "Post-processing", + Name: "Add movie to Radarr after processing", + Type: "Video", + Operation: "", + Description: `[TESTING]Add movie to Radarr after processing \n\n`, + Version: "1.00", + Link: "", + + Inputs: [ + { + name: 'server_ip', + tooltip: ` + Enter the server IP address + + \\nExample:\\n + 192.168.0.10 + ` + }, + { + name: 'port', + tooltip: ` + Enter the port Radarr is using + + \\nExample:\\n + 7878 + ` + }, + { + name: 'radarr_api_key', + tooltip: ` + + Enter the Radarr API key. You can find it on Radarr at /settings/general + + \\nExample:\\n + 3ff1ae1c39a2a2a397315e15266dea48 + ` + }, + ] + } +} + +module.exports.plugin = function plugin(file, librarySettings, inputs) { + + + + const request = require('request') + + const IP = inputs.server_ip + const port = inputs.port + const APIKey = inputs.radarr_api_key + + + var term = file.file.split("/") + term = term[term.length - 1] + term = term.split(".") + term = term[term.length - 2] + term = encodeURI(term) + + + console.log(IP) + console.log(term) + + request.get(`http://${IP}:${port}/api/movie/lookup?term=${term}&apikey=${APIKey}`, { + json: { + } + }, (error, res, body) => { + if (error) { + console.error(error) + } + // console.log(`statusCode: ${res.statusCode}`) + //console.log(body) + + + var response = body[0] + console.log(response.title) //Shrek + + + response.profileId = 6 + response.path = file.file + response.qualityProfile = 6 + + + request.post(`http://${IP}:${port}/api/movie?apikey=${APIKey}`, { + json: response + }, (error, res, body) => { + if (error) { + console.error(error) + } + console.log(`statusCode: ${res.statusCode}`) + // console.log(body) + }) + + }) + + + //Optional response if you need to modify database + var response = { + file, + removeFromDB: false, + updateDB: false, + } + + //return response + +} +