- Add more indepth stats like number of torrents, profile details etc

- Add torrent ingest endpoints
- Add issue template
This commit is contained in:
Mukhtar Akere
2025-05-29 04:05:44 +01:00
parent f9c49cbbef
commit 1cd09239f9
25 changed files with 411 additions and 369 deletions
+36 -2
View File
@@ -45,9 +45,10 @@ type RealDebrid struct {
rarSemaphore chan struct{}
checkCached bool
addSamples bool
Profile *types.Profile
}
func New(dc config.Debrid) *RealDebrid {
func New(dc config.Debrid) (*RealDebrid, error) {
rl := request.ParseRateLimit(dc.RateLimit)
headers := map[string]string{
@@ -70,7 +71,7 @@ func New(dc config.Debrid) *RealDebrid {
"Authorization": fmt.Sprintf("Bearer %s", currentDownloadKey),
}
return &RealDebrid{
r := &RealDebrid{
Name: "realdebrid",
Host: "https://api.real-debrid.com/rest/1.0",
APIKey: dc.APIKey,
@@ -99,6 +100,12 @@ func New(dc config.Debrid) *RealDebrid {
checkCached: dc.CheckCached,
addSamples: dc.AddSamples,
}
if _, err := r.GetProfile(); err != nil {
return nil, err
} else {
return r, nil
}
}
func (r *RealDebrid) GetName() string {
@@ -908,3 +915,30 @@ func (r *RealDebrid) DeleteDownloadLink(linkId string) error {
}
return nil
}
func (r *RealDebrid) GetProfile() (*types.Profile, error) {
if r.Profile != nil {
return r.Profile, nil
}
url := fmt.Sprintf("%s/user", r.Host)
req, _ := http.NewRequest(http.MethodGet, url, nil)
resp, err := r.client.MakeRequest(req)
if err != nil {
return nil, err
}
var data profileResponse
if json.Unmarshal(resp, &data) != nil {
return nil, err
}
profile := &types.Profile{
Id: data.Id,
Username: data.Username,
Email: data.Email,
Points: data.Points,
Premium: data.Premium,
Expiration: data.Expiration,
Type: data.Type,
}
return profile, nil
}
+12
View File
@@ -139,3 +139,15 @@ type ErrorResponse struct {
Error string `json:"error"`
ErrorCode int `json:"error_code"`
}
type profileResponse struct {
Id int64 `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
Points int64 `json:"points"`
Locale string `json:"locale"`
Avatar string `json:"avatar"`
Type string `json:"type"`
Premium int `json:"premium"`
Expiration time.Time `json:"expiration"`
}