Report traffic for all download tokens
This commit is contained in:
@@ -338,12 +338,12 @@ func (rd *RealDebrid) GetUserInformation() (*User, error) {
|
||||
|
||||
// TrafficDetails represents the structure of the traffic details response
|
||||
type TrafficDetails map[string]struct {
|
||||
Host map[string]int64 `json:"host"`
|
||||
Bytes int64 `json:"bytes"`
|
||||
Host map[string]uint64 `json:"host"`
|
||||
Bytes int64 `json:"bytes"`
|
||||
}
|
||||
|
||||
// GetTrafficDetails gets the traffic details from the Real-Debrid API
|
||||
func (rd *RealDebrid) GetTrafficDetails() (map[string]int64, error) {
|
||||
func (rd *RealDebrid) GetTrafficDetails(token string) (map[string]uint64, error) {
|
||||
// Construct request URL
|
||||
reqURL := "https://api.real-debrid.com/rest/1.0/traffic/details"
|
||||
req, err := http.NewRequest(http.MethodGet, reqURL, nil)
|
||||
@@ -352,6 +352,8 @@ func (rd *RealDebrid) GetTrafficDetails() (map[string]int64, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
|
||||
// Send the request
|
||||
resp, err := rd.apiClient.Do(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -102,3 +102,11 @@ func (dtm *DownloadTokenManager) GetExpiredTokens() []string {
|
||||
}
|
||||
return tokens
|
||||
}
|
||||
|
||||
func (dtm *DownloadTokenManager) GetAllTokens() []string {
|
||||
var tokens []string
|
||||
for _, t := range dtm.tokens {
|
||||
tokens = append(tokens, t.value)
|
||||
}
|
||||
return tokens
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user