Add bins to home page

This commit is contained in:
Ben Sarmiento
2024-05-25 01:54:35 +02:00
parent abb80b4257
commit a681912fc1
3 changed files with 53 additions and 38 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/debridmediamanager/zurg/internal/config"
"github.com/debridmediamanager/zurg/internal/version"
"github.com/debridmediamanager/zurg/pkg/realdebrid"
mapset "github.com/deckarep/golang-set/v2"
)
type SponsorResponse struct {
@@ -18,21 +19,23 @@ type SponsorResponse struct {
Paypal string `json:"paypal"`
}
type RootResponse struct {
Version string `json:"version"`
BuiltAt string `json:"built_at"`
GitCommit string `json:"git_commit"`
Html string `json:"html"`
Dav string `json:"dav"`
Infuse string `json:"infuse"`
Logs string `json:"logs"`
UserInfo *realdebrid.User `json:"user_info"` // Replace UserInfoType with the actual type
MemAlloc uint64 `json:"mem_alloc"` // Memory allocation in MB
TotalAlloc uint64 `json:"total_alloc"` // Total memory allocated in MB
Sys uint64 `json:"sys"` // System memory in MB
NumGC uint32 `json:"num_gc"` // Number of completed GC cycles
PID int `json:"pid"` // Process ID
Sponsor SponsorResponse `json:"sponsor_zurg"` // Sponsorship links
Config config.ZurgConfig `json:"config"`
Version string `json:"version"`
BuiltAt string `json:"built_at"`
GitCommit string `json:"git_commit"`
Html string `json:"html"`
Dav string `json:"dav"`
Infuse string `json:"infuse"`
Logs string `json:"logs"`
UserInfo *realdebrid.User `json:"user_info"` // Replace UserInfoType with the actual type
MemAlloc uint64 `json:"mem_alloc"` // Memory allocation in MB
TotalAlloc uint64 `json:"total_alloc"` // Total memory allocated in MB
Sys uint64 `json:"sys"` // System memory in MB
NumGC uint32 `json:"num_gc"` // Number of completed GC cycles
PID int `json:"pid"` // Process ID
Sponsor SponsorResponse `json:"sponsor_zurg"` // Sponsorship links
Config config.ZurgConfig `json:"config"`
ImmediateBin mapset.Set[string] `json:"immediate_bin"`
OnceDoneBin mapset.Set[string] `json:"once_done_bin"`
}
func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
@@ -64,7 +67,9 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
Github: "https://github.com/sponsors/debridmediamanager",
Paypal: "https://paypal.me/yowmamasita",
},
Config: zr.cfg.GetConfig(),
Config: zr.cfg.GetConfig(),
ImmediateBin: zr.torMgr.ImmediateBin,
OnceDoneBin: zr.torMgr.OnceDoneBin,
}
out := `<table border="1px">
@@ -244,6 +249,14 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
</tr>
<tr>
<td>On Library Update</td>
<td>%v</td>
</tr>
<tr>
<td>Immediate Bin</td>
<td>%s</td>
</tr>
<tr>
<td>Once Done Bin</td>
<td>%s</td>
</tr>
<tr>
@@ -321,6 +334,8 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
response.Config.ShouldServeFromRclone(),
response.Config.ShouldForceIPv6(),
response.Config.GetOnLibraryUpdate(),
response.ImmediateBin.String(),
response.OnceDoneBin.String(),
)
fmt.Fprint(resp, out)