]> git.immae.eu Git - github/bastienwirtz/homer.git/commitdiff
Radarr and Sonarr V3 api support optional
authorDuy NGUYEN <duynguyen@deevotech.com>
Tue, 1 Feb 2022 16:05:23 +0000 (17:05 +0100)
committerDuy NGUYEN <duynguyen@deevotech.com>
Tue, 1 Feb 2022 16:05:23 +0000 (17:05 +0100)
docs/customservices.md
src/components/services/Radarr.vue
src/components/services/Sonarr.vue

index 77109b7cb5ac7d95a5c65d368b265a7006d1c7f8..91c4051e9d83154eee52ce406a49403bd1a9285b 100644 (file)
@@ -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
 
index a8c97c1992cbd0e448b3b8884a37c2e5656c6686..13f6d68840e0c7813ccf018abb56d9a85f81577c 100644 (file)
@@ -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++) {
index 972a1c9fc3a001887860db1d9eb199783dd8ba69..3e5c49fb938459e15e60deddcacbfc760bda3777 100644 (file)
@@ -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++) {