Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added download rate & added dummy-data for SABnzbd #661

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/customservices.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ the "Config" > "General" section of the SABnzbd config in the SABnzbd web UI.
url: "http://192.168.0.151:8080"
type: "SABnzbd"
apikey: "MY-SUPER-SECRET-API-KEY"
downloadInterval: 5000 # (Optional) Interval (in ms) for updating the download count
downloadInterval: 5000 # (Optional) Interval (in ms) for updating the stats
rateDisabled: false
```

## OctoPrint/Moonraker
Expand Down
59 changes: 59 additions & 0 deletions dummy-data/SABnzbd/api
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"queue": {
"version": "4.0.2",
"paused": false,
"pause_int": "0",
"paused_all": false,
"diskspace1": "900.28",
"diskspace2": "900.28",
"diskspace1_norm": "900.3 G",
"diskspace2_norm": "900.3 G",
"diskspacetotal1": "901.23",
"diskspacetotal2": "901.23",
"speedlimit": "1",
"speedlimit_abs": "1310720",
"have_warnings": "0",
"finishaction": null,
"quota": "0 ",
"have_quota": false,
"left_quota": "0 ",
"cache_art": "16",
"cache_size": "10.9 MB",
"kbpersec": "1286.74",
"speed": "1.3 M",
"mbleft": "9492.27",
"mb": "11629.75",
"sizeleft": "9.3 GB",
"size": "11.4 GB",
"noofslots_total": 1,
"noofslots": 1,
"start": 0,
"limit": 0,
"finish": 0,
"status": "Downloading",
"timeleft": "2:05:54",
"slots": [
{
"index": 0,
"nzo_id": "SABnzbd_nzo_nviz7k64",
"unpackopts": "3",
"priority": "Force",
"script": "None",
"filename": "test_download_10GB",
"labels": [],
"password": "",
"cat": "*",
"mbleft": "9492.27",
"mb": "11629.75",
"size": "11.4 GB",
"sizeleft": "9.3 GB",
"percentage": "18",
"mbmissing": "0.00",
"direct_unpack": null,
"status": "Downloading",
"timeleft": "2:05:54",
"avg_age": "335d"
}
]
}
}
36 changes: 35 additions & 1 deletion src/components/services/SABnzbd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@
<i
v-if="error"
class="notif error fa-solid fa-triangle-exclamation"
title="Unable to fetch current status"
title="Unable to fetch current download count"
></i>
</div>
<div class="notifs notifs-down">
<strong
v-if="!this.item.rateDisabled && downloads > 0"
class="notif downloading"
:title="`${downRate}B/s `"
>
{{ downRate }}B/s
</strong>
<i
v-if="error"
class="notif error fa-solid fa-triangle-exclamation"
title="Unable to fetch current download speed"
></i>
</div>
</template>
Expand Down Expand Up @@ -43,9 +57,24 @@ export default {
}
return this.stats.noofslots;
},
downRate: function() {
if (!this.stats) {
return "";
}
return this.stats.speed;
},
},
created() {
const downloadInterval = parseInt(this.item.downloadInterval, 10) || 0;
const apikey = this.item.apikey;

if (!apikey) {
console.error(
"apikey is not present in config.yml for the SABnzbd entry!"
);
return;
}

if (downloadInterval > 0) {
setInterval(() => this.fetchStatus(), downloadInterval);
}
Expand All @@ -70,6 +99,11 @@ export default {
</script>

<style scoped lang="scss">
.notifs-down {
top: unset !important;
bottom: 0.3em;
}

.notifs {
position: absolute;
color: white;
Expand Down