Reworked Models to use tmdb to enable integration with Radarr api. Also reworked test connection to use api to validate as I ran into CORS errors. I also set up an endpoint to call radarr to delete movies. Currently only got to retrieving movie info. Should be able to use the id retrieved to then delete the movie.

This commit is contained in:
2026-03-07 18:02:45 -07:00
parent 958c581280
commit 3f5074aa3b
7 changed files with 276 additions and 70 deletions

View File

@@ -37,7 +37,7 @@ const testConnectionSonarr = async () => {
var addressElement = document.getElementById('SonarrAddress');
var validationElement = document.getElementById('SonarrConnectionValidation');
await validateConnection(apiKeyElement, addressElement, validationElement);
await validateConnection(apiKeyElement, addressElement, validationElement, "sonarr");
}
const testConnectionRadarr = async () => {
@@ -45,7 +45,7 @@ const testConnectionRadarr = async () => {
var addressElement = document.getElementById('RadarrAddress');
var validationElement = document.getElementById('RadarrConnectionValidation');
await validateConnection(apiKeyElement, addressElement, validationElement);
await validateConnection(apiKeyElement, addressElement, validationElement, "radarr");
}
// Validation and Normalization
@@ -57,7 +57,7 @@ const normalizeUrl = (url) => {
return normalizedUrl;
};
const validateConnection = async (apiKeyElement, addressElement, validationElement) => {
const validateConnection = async (apiKeyElement, addressElement, validationElement, controller) => {
var httpAddress = addressElement.value;
var apiKey = apiKeyElement.value;
@@ -77,13 +77,19 @@ const validateConnection = async (apiKeyElement, addressElement, validationEleme
setAttemptingConnection(validationElement);
try{
const url = normalizeUrl(httpAddress);
const response = await fetch(url, {
method: "GET",
// Move endpoint to a constant?
const response = await fetch(`/${controller}/testConnection`, {
method: "POST",
headers: {
"X-Api-Key": apiKey,
}
"Content-Type": "application/json"
},
body: JSON.stringify({ address: url, apiKey })
});
success = response.ok;
if (response.ok) {
const result = await response.json();
success = result?.success === true;
}
}
catch (error){
console.error(`Error: ${error}`);