mirror of
https://codeberg.org/hyperreal/go-transmission-stats
synced 2024-11-25 12:13:42 +01:00
Use env variables for RPC auth
This commit is contained in:
parent
34f1a53f73
commit
90bc1df230
@ -8,7 +8,7 @@ For other people using this, change the stylesheet in `template.html` to your pr
|
||||
transmissionbt, err := transmissionrpc.New("<your Transmission server ip>", "username", "password", nil)
|
||||
```
|
||||
|
||||
My personal use case for this involves running the Go binary `go-transmission-stats` on a systemd timer that triggers the corresponding service every 12 hours. The systemd service looks like this:
|
||||
My personal use case for this involves running the Go binary `go-transmission-stats` on a systemd timer that triggers the corresponding service every 12 hours.
|
||||
|
||||
First build the binary:
|
||||
|
||||
|
6
main.go
6
main.go
@ -79,7 +79,7 @@ type TorrentStatsPageData struct {
|
||||
}
|
||||
|
||||
func main() {
|
||||
transmissionbt, err := transmissionrpc.New("", "", "", nil)
|
||||
transmissionbt, err := transmissionrpc.New(os.Getenv("RPC_HOST"), os.Getenv("RPC_USER"), os.Getenv("RPC_PASSWD"), nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -103,7 +103,7 @@ func main() {
|
||||
{Label: "Uploaded/Downloaded ratio", Value: fmt.Sprintf("%d", *&stats.CurrentStats.UploadedBytes / *&stats.CurrentStats.DownloadedBytes)},
|
||||
{Label: "Files added", Value: fmt.Sprintf("%d", *&stats.CurrentStats.FilesAdded)},
|
||||
{Label: "Session count", Value: fmt.Sprintf("%d", *&stats.CurrentStats.SessionCount)},
|
||||
{Label: "Seconds active", Value: convertTime(*&stats.CurrentStats.SecondsActive)},
|
||||
{Label: "Time active", Value: convertTime(*&stats.CurrentStats.SecondsActive)},
|
||||
}
|
||||
|
||||
cumulativeStats := []SessionStat{
|
||||
@ -112,7 +112,7 @@ func main() {
|
||||
{Label: "Uploaded/Downloaded ratio", Value: fmt.Sprintf("%d", *&stats.CumulativeStats.UploadedBytes / *&stats.CumulativeStats.DownloadedBytes)},
|
||||
{Label: "Files added", Value: fmt.Sprintf("%d", *&stats.CumulativeStats.FilesAdded)},
|
||||
{Label: "Session count", Value: fmt.Sprintf("%d", *&stats.CumulativeStats.SessionCount)},
|
||||
{Label: "Seconds active", Value: convertTime(*&stats.CumulativeStats.SecondsActive)},
|
||||
{Label: "Time active", Value: convertTime(*&stats.CumulativeStats.SecondsActive)},
|
||||
}
|
||||
|
||||
var torrentInfo = []TorrentInfo{}
|
||||
|
@ -5,22 +5,7 @@
|
||||
<link rel="icon" type="image/x-icon" href="coffee.svg">
|
||||
<link href="catppuccin.css" rel="stylesheet">
|
||||
</head>
|
||||
<style>
|
||||
table, th, td {
|
||||
border:1px solid #7f849c;
|
||||
border-collapse: collapse;
|
||||
padding: 10px;
|
||||
}
|
||||
table {
|
||||
margin-top: 24px;
|
||||
}
|
||||
.name {
|
||||
color: #a6e3a1;
|
||||
}
|
||||
.container {
|
||||
margin-bottom: 64px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Torrent Stats</h1>
|
||||
|
Loading…
Reference in New Issue
Block a user