aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorroyto <royto81+github@gmail.com>2023-07-22 22:55:00 +0200
committerBastien Wirtz <bastien.wirtz@gmail.com>2023-08-08 12:48:44 -0700
commit16d3f4f53a4f4be77ace6f4f140e2e639ee761d9 (patch)
tree06fa7ac669c3f812e49ac51d76d0a6af63feacf9
parentf682a84e9ffc667c92dd2dac5efaab9d7280540d (diff)
downloadhomer-16d3f4f53a4f4be77ace6f4f140e2e639ee761d9.tar.gz
homer-16d3f4f53a4f4be77ace6f4f140e2e639ee761d9.tar.zst
homer-16d3f4f53a4f4be77ace6f4f140e2e639ee761d9.zip
feat: add Readarr custom service
-rw-r--r--docs/customservices.md9
-rw-r--r--src/components/services/Readarr.vue117
2 files changed, 122 insertions, 4 deletions
diff --git a/docs/customservices.md b/docs/customservices.md
index cb897a2..8415b5a 100644
--- a/docs/customservices.md
+++ b/docs/customservices.md
@@ -98,9 +98,10 @@ Two lines are needed in the config.yml :
98The url must be the root url of Medusa application. 98The url must be the root url of Medusa application.
99The Medusa API key can be found in General configuration > Interface. It is needed to access Medusa API. 99The Medusa API key can be found in General configuration > Interface. It is needed to access Medusa API.
100 100
101## Lidarr, Prowlarr, Sonarr and Radarr 101## Lidarr, Prowlarr, Sonarr, Readarr and Radarr
102 102
103This service displays Activity (blue), Warning (orange) or Error (red) notifications bubbles from the Lidarr, Radarr or Sonarr application. 103This service displays Activity (blue), Warning (orange) or Error (red) notifications bubbles from the Lidarr, Readarr, Radarr or Sonarr application.
104Readarr display also a Missing (purple) notification bubbles.
104Two lines are needed in the config.yml : 105Two lines are needed in the config.yml :
105 106
106```yaml 107```yaml
@@ -108,8 +109,8 @@ Two lines are needed in the config.yml :
108 apikey: "<---insert-api-key-here--->" 109 apikey: "<---insert-api-key-here--->"
109``` 110```
110 111
111The url must be the root url of Lidarr, Prowlarr, Radarr or Sonarr application. 112The url must be the root url of Lidarr, Prowlarr, Readarr, Radarr or Sonarr application.
112The Lidarr, Prowlarr, Radarr or Sonarr API key can be found in Settings > General. It is needed to access the API. 113The Lidarr, Prowlarr, Readarr, Radarr or Sonarr API key can be found in Settings > General. It is needed to access the API.
113If 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: 114If 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:
114 115
115```yaml 116```yaml
diff --git a/src/components/services/Readarr.vue b/src/components/services/Readarr.vue
new file mode 100644
index 0000000..d921c29
--- /dev/null
+++ b/src/components/services/Readarr.vue
@@ -0,0 +1,117 @@
1<template>
2 <Generic :item="item">
3 <template #indicator>
4 <div class="notifs">
5 <strong v-if="activity > 0" class="notif activity" title="Activity">
6 {{ activity }}
7 </strong>
8 <strong v-if="missing > 0" class="notif missing" title="Missing">
9 {{ missing }}
10 </strong>
11 <strong v-if="warnings > 0" class="notif warnings" title="Warning">
12 {{ warnings }}
13 </strong>
14 <strong v-if="errors > 0" class="notif errors" title="Error">
15 {{ errors }}
16 </strong>
17 <strong
18 v-if="serverError"
19 class="notif errors"
20 title="Connection error to Readarr API, check url and apikey in config.yml"
21 >?</strong
22 >
23 </div>
24 </template>
25 </Generic>
26</template>
27
28<script>
29import service from "@/mixins/service.js";
30import Generic from "./Generic.vue";
31
32const API = "/api/v1";
33
34export default {
35 name: "Readarr",
36 mixins: [service],
37 props: {
38 item: Object,
39 },
40 components: {
41 Generic,
42 },
43 data: () => {
44 return {
45 activity: null,
46 missing: null,
47 warnings: null,
48 errors: null,
49 serverError: false,
50 };
51 },
52 created: function () {
53 this.fetchConfig();
54 },
55 computed: {
56 apiPath() {
57 return API;
58 },
59 },
60 methods: {
61 fetchConfig: function () {
62 const handleError = (e) => {
63 console.error(e);
64 this.serverError = true;
65 }
66 this.fetch(`${this.apiPath}/health?apikey=${this.item.apikey}`)
67 .then((health) => {
68 this.warnings = health.filter(h => h.type === 'warning').length;
69 this.errors = health.filter(h => h.type === 'errors').length;
70 })
71 .catch(handleError);
72 this.fetch(`${this.apiPath}/queue?apikey=${this.item.apikey}`)
73 .then((queue) => {
74 this.activity = queue.totalRecords;
75 })
76 .catch(handleError);
77 this.fetch(`${this.apiPath}/wanted/missing?apikey=${this.item.apikey}`)
78 .then((missing) => {
79 this.missing = missing.totalRecords;
80 })
81 .catch(handleError);
82 },
83 },
84};
85</script>
86
87<style scoped lang="scss">
88.notifs {
89 position: absolute;
90 color: white;
91 font-family: sans-serif;
92 top: 0.3em;
93 right: 0.5em;
94 display: flex;
95 gap: 0.2rem;
96 .notif {
97 padding: 0.2em 0.35em;
98 border-radius: 0.25em;
99 font-size: 0.8em;
100 &.activity {
101 background-color: #4fb5d6;
102 }
103
104 &.missing {
105 background-color: #9d00ff;
106 }
107
108 &.warnings {
109 background-color: #d08d2e;
110 }
111
112 &.errors {
113 background-color: #e51111;
114 }
115 }
116}
117</style>