From cb154a6818cd25a36298e307cb415b11e9bd2247 Mon Sep 17 00:00:00 2001 From: Duy NGUYEN Date: Tue, 1 Feb 2022 16:39:15 +0100 Subject: Update Sonarr and Radarr API --- src/components/services/Radarr.vue | 4 ++-- src/components/services/Sonarr.vue | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/services/Radarr.vue b/src/components/services/Radarr.vue index a57c895..a8c97c1 100644 --- a/src/components/services/Radarr.vue +++ b/src/components/services/Radarr.vue @@ -48,7 +48,7 @@ export default { }, methods: { fetchConfig: function () { - this.fetch(`/api/health?apikey=${this.item.apikey}`) + this.fetch(`/api/v3/health?apikey=${this.item.apikey}`) .then((health) => { this.warnings = 0; this.errors = 0; @@ -64,7 +64,7 @@ export default { console.error(e); this.serverError = true; }); - this.fetch(`/api/queue?apikey=${this.item.apikey}`) + this.fetch(`/api/v3/queue?apikey=${this.item.apikey}`) .then((queue) => { this.activity = 0; for (var i = 0; i < queue.length; i++) { diff --git a/src/components/services/Sonarr.vue b/src/components/services/Sonarr.vue index f8dd0d1..972a1c9 100644 --- a/src/components/services/Sonarr.vue +++ b/src/components/services/Sonarr.vue @@ -49,7 +49,7 @@ export default { }, methods: { fetchConfig: function () { - this.fetch(`/api/health?apikey=${this.item.apikey}`) + this.fetch(`/api/v3/health?apikey=${this.item.apikey}`) .then((health) => { this.warnings = 0; this.errors = 0; @@ -65,7 +65,7 @@ export default { console.error(e); this.serverError = true; }); - this.fetch(`/api/queue?apikey=${this.item.apikey}`) + this.fetch(`/api/v3/queue?apikey=${this.item.apikey}`) .then((queue) => { this.activity = 0; for (var i = 0; i < queue.length; i++) { -- cgit v1.2.3 From 8ede30411ed1726ed3885fd617364924e677abc2 Mon Sep 17 00:00:00 2001 From: Duy NGUYEN Date: Tue, 1 Feb 2022 17:05:23 +0100 Subject: Radarr and Sonarr V3 api support optional --- docs/customservices.md | 10 ++++++++++ src/components/services/Radarr.vue | 12 ++++++++++-- src/components/services/Sonarr.vue | 12 ++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/docs/customservices.md b/docs/customservices.md index 77109b7..91c4051 100644 --- a/docs/customservices.md +++ b/docs/customservices.md @@ -79,6 +79,16 @@ Two lines are needed in the config.yml : The url must be the root url of Lidarr, Radarr or Sonarr application. The Lidarr, Radarr or Sonarr API key can be found in Settings > General. It is needed to access the API. +If you are using an older version of Radarr or Sonarr which don't support the new V3 api endpoints, add the following line to your service config "legacyApi: true", example: + +```yaml +- name: "Radarr" + type: "Radarr" + url: "http://localhost:8989/" + apikey: "MY-SUPER-SECRET-API-KEY" + target: "_blank" # optional html tag target attribute + legacyApi: true +``` ## PaperlessNG diff --git a/src/components/services/Radarr.vue b/src/components/services/Radarr.vue index a8c97c1..13f6d68 100644 --- a/src/components/services/Radarr.vue +++ b/src/components/services/Radarr.vue @@ -26,6 +26,9 @@ import service from "@/mixins/service.js"; import Generic from "./Generic.vue"; +const V3_API = "/api/v3"; +const LEGACY_API = "/api"; + export default { name: "Radarr", mixins: [service], @@ -46,9 +49,14 @@ export default { created: function () { this.fetchConfig(); }, + computed: { + apiPath() { + return this.item.legacyApi ? LEGACY_API : V3_API; + }, + }, methods: { fetchConfig: function () { - this.fetch(`/api/v3/health?apikey=${this.item.apikey}`) + this.fetch(`${this.apiPath}/health?apikey=${this.item.apikey}`) .then((health) => { this.warnings = 0; this.errors = 0; @@ -64,7 +72,7 @@ export default { console.error(e); this.serverError = true; }); - this.fetch(`/api/v3/queue?apikey=${this.item.apikey}`) + this.fetch(`${this.apiPath}/queue?apikey=${this.item.apikey}`) .then((queue) => { this.activity = 0; for (var i = 0; i < queue.length; i++) { diff --git a/src/components/services/Sonarr.vue b/src/components/services/Sonarr.vue index 972a1c9..3e5c49f 100644 --- a/src/components/services/Sonarr.vue +++ b/src/components/services/Sonarr.vue @@ -27,6 +27,9 @@ import service from "@/mixins/service.js"; import Generic from "./Generic.vue"; +const V3_API = "/api/v3"; +const LEGACY_API = "/api"; + export default { name: "Sonarr", mixins: [service], @@ -36,6 +39,11 @@ export default { components: { Generic, }, + computed: { + apiPath() { + return this.item.legacyApi ? LEGACY_API : V3_API; + }, + }, data: () => { return { activity: null, @@ -49,7 +57,7 @@ export default { }, methods: { fetchConfig: function () { - this.fetch(`/api/v3/health?apikey=${this.item.apikey}`) + this.fetch(`${this.apiPath}/health?apikey=${this.item.apikey}`) .then((health) => { this.warnings = 0; this.errors = 0; @@ -65,7 +73,7 @@ export default { console.error(e); this.serverError = true; }); - this.fetch(`/api/v3/queue?apikey=${this.item.apikey}`) + this.fetch(`${this.apiPath}/queue?apikey=${this.item.apikey}`) .then((queue) => { this.activity = 0; for (var i = 0; i < queue.length; i++) { -- cgit v1.2.3 From f7f4ebdf667db848509f93d470cd46c648bb2439 Mon Sep 17 00:00:00 2001 From: Duy NGUYEN Date: Tue, 1 Feb 2022 18:32:25 +0100 Subject: Parse new V3 api response --- docs/customservices.md | 4 ++-- src/components/services/Radarr.vue | 15 ++++++++++++--- src/components/services/Sonarr.vue | 14 +++++++++++--- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/docs/customservices.md b/docs/customservices.md index 91c4051..9317907 100644 --- a/docs/customservices.md +++ b/docs/customservices.md @@ -84,9 +84,9 @@ If you are using an older version of Radarr or Sonarr which don't support the ne ```yaml - name: "Radarr" type: "Radarr" - url: "http://localhost:8989/" + url: "http://localhost:7878/" apikey: "MY-SUPER-SECRET-API-KEY" - target: "_blank" # optional html tag target attribute + target: "_blank" legacyApi: true ``` diff --git a/src/components/services/Radarr.vue b/src/components/services/Radarr.vue index 13f6d68..55896f5 100644 --- a/src/components/services/Radarr.vue +++ b/src/components/services/Radarr.vue @@ -75,9 +75,18 @@ export default { this.fetch(`${this.apiPath}/queue?apikey=${this.item.apikey}`) .then((queue) => { this.activity = 0; - for (var i = 0; i < queue.length; i++) { - if (queue[i].movie) { - this.activity++; + + if (this.item.legacyApi) { + for (var i = 0; i < queue.length; i++) { + if (queue[i].series) { + this.activity++; + } + } + } else { + for (const record of queue.records) { + if (record.movieId) { + this.activity++; + } } } }) diff --git a/src/components/services/Sonarr.vue b/src/components/services/Sonarr.vue index 3e5c49f..55df437 100644 --- a/src/components/services/Sonarr.vue +++ b/src/components/services/Sonarr.vue @@ -76,9 +76,17 @@ export default { this.fetch(`${this.apiPath}/queue?apikey=${this.item.apikey}`) .then((queue) => { this.activity = 0; - for (var i = 0; i < queue.length; i++) { - if (queue[i].series) { - this.activity++; + if (this.item.legacyApi) { + for (var i = 0; i < queue.length; i++) { + if (queue[i].series) { + this.activity++; + } + } + } else { + for (const record of queue.records) { + if (record.seriesId) { + this.activity++; + } } } }) -- cgit v1.2.3 From 6c8f9f1c5b440e9cf837a9ecaf9fd4b52815387c Mon Sep 17 00:00:00 2001 From: Duy NGUYEN Date: Tue, 1 Feb 2022 23:01:09 +0100 Subject: Fix radarr legacy api call --- src/components/services/Radarr.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/services/Radarr.vue b/src/components/services/Radarr.vue index 55896f5..7573667 100644 --- a/src/components/services/Radarr.vue +++ b/src/components/services/Radarr.vue @@ -78,7 +78,7 @@ export default { if (this.item.legacyApi) { for (var i = 0; i < queue.length; i++) { - if (queue[i].series) { + if (queue[i].movie) { this.activity++; } } -- cgit v1.2.3