Multi-token support
This commit is contained in:
@@ -29,7 +29,7 @@ type RootResponse struct {
|
||||
Infuse string `json:"infuse"`
|
||||
Logs string `json:"logs"`
|
||||
UserInfo *realdebrid.User `json:"user_info"`
|
||||
TrafficLogged uint64 `json:"traffic_logged"`
|
||||
APITrafficMB uint64 `json:"traffic_from_api"`
|
||||
RequestedMB uint64 `json:"requested_mb"`
|
||||
ServedMB uint64 `json:"served_mb"`
|
||||
LibrarySize int `json:"library_size"` // Number of torrents in the library
|
||||
@@ -82,10 +82,10 @@ func (zr *Handlers) generateResponse(resp http.ResponseWriter, req *http.Request
|
||||
http.Error(resp, err.Error(), http.StatusInternalServerError)
|
||||
return nil, err
|
||||
}
|
||||
var trafficLogged int64
|
||||
trafficLogged = 0
|
||||
var trafficFromAPI int64
|
||||
trafficFromAPI = 0
|
||||
if _, ok := trafficDetails["real-debrid.com"]; ok {
|
||||
trafficLogged = trafficDetails["real-debrid.com"]
|
||||
trafficFromAPI = trafficDetails["real-debrid.com"]
|
||||
}
|
||||
|
||||
userInfo.Premium = userInfo.Premium / 86400
|
||||
@@ -101,7 +101,7 @@ func (zr *Handlers) generateResponse(resp http.ResponseWriter, req *http.Request
|
||||
Infuse: fmt.Sprintf("//%s/infuse/", req.Host),
|
||||
Logs: fmt.Sprintf("//%s/logs/", req.Host),
|
||||
UserInfo: userInfo,
|
||||
TrafficLogged: bToMb(uint64(trafficLogged)),
|
||||
APITrafficMB: bToMb(uint64(trafficFromAPI)),
|
||||
RequestedMB: bToMb(zr.downloader.RequestedBytes.Load()),
|
||||
ServedMB: bToMb(zr.downloader.TotalBytes.Load()),
|
||||
LibrarySize: allTorrents.Count(),
|
||||
@@ -198,10 +198,10 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
efficiency := response.ServedMB * 100 / denominator
|
||||
|
||||
if zr.initialTraffic.Load() > response.TrafficLogged {
|
||||
if zr.trafficOnStartup.Load() > response.APITrafficMB {
|
||||
// it cannot be bigger than traffic logged
|
||||
// so it must be a reset back to 0
|
||||
zr.initialTraffic.Store(0)
|
||||
zr.trafficOnStartup.Store(response.APITrafficMB * 1024 * 1024)
|
||||
}
|
||||
|
||||
out += fmt.Sprintf(`
|
||||
@@ -251,8 +251,8 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
||||
response.Sys,
|
||||
response.NumGC,
|
||||
response.PID,
|
||||
response.TrafficLogged,
|
||||
response.TrafficLogged-bToMb(zr.initialTraffic.Load()),
|
||||
response.APITrafficMB,
|
||||
response.APITrafficMB-bToMb(zr.trafficOnStartup.Load()),
|
||||
response.RequestedMB,
|
||||
response.ServedMB,
|
||||
efficiency,
|
||||
|
||||
Reference in New Issue
Block a user