67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package realdebrid
|
|
|
|
import (
|
|
"encoding/json"
|
|
"math"
|
|
)
|
|
|
|
type FileJSON struct {
|
|
FileSize int `json:"filesize"`
|
|
Link string `json:"link"`
|
|
}
|
|
|
|
type UnrestrictResponse struct {
|
|
Filename string `json:"filename"`
|
|
Filesize int64 `json:"filesize"`
|
|
Link string `json:"link"`
|
|
Host string `json:"host"`
|
|
Download string `json:"download,omitempty"`
|
|
Streamable int `json:"streamable"`
|
|
}
|
|
|
|
type Torrent struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"filename"`
|
|
OriginalName string `json:"original_filename"`
|
|
Hash string `json:"hash"`
|
|
Progress int `json:"-"`
|
|
Added string `json:"added"`
|
|
Bytes int64 `json:"bytes"`
|
|
Links []string `json:"links"`
|
|
Files []File `json:"files,omitempty"`
|
|
}
|
|
|
|
func (t *Torrent) UnmarshalJSON(data []byte) error {
|
|
type Alias Torrent
|
|
aux := &struct {
|
|
Progress float64 `json:"progress"`
|
|
*Alias
|
|
}{
|
|
Alias: (*Alias)(t),
|
|
}
|
|
|
|
if err := json.Unmarshal(data, &aux); err != nil {
|
|
return err
|
|
}
|
|
|
|
t.Progress = int(math.Round(aux.Progress))
|
|
return nil
|
|
}
|
|
|
|
type File struct {
|
|
ID int `json:"id"`
|
|
Path string `json:"path"`
|
|
Bytes int64 `json:"bytes"`
|
|
Selected int `json:"selected"`
|
|
}
|
|
|
|
type MagnetResponse struct {
|
|
ID string `json:"id"`
|
|
URI string `json:"uri"`
|
|
}
|
|
|
|
type ActiveTorrentCountResponse struct {
|
|
DownloadingCount int `json:"nb"`
|
|
MaxNumberOfTorrents int `json:"limit"`
|
|
}
|