Process timestamps properly
This commit is contained in:
@@ -3,6 +3,7 @@ package realdebrid
|
||||
import (
|
||||
"encoding/json"
|
||||
"math"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type FileJSON struct {
|
||||
@@ -22,10 +23,7 @@ type UnrestrictResponse struct {
|
||||
type Torrent struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"filename"`
|
||||
Hash string `json:"hash"`
|
||||
Progress int `json:"-"`
|
||||
Added string `json:"added"`
|
||||
Bytes int64 `json:"bytes"`
|
||||
Links []string `json:"links"`
|
||||
}
|
||||
|
||||
@@ -52,13 +50,13 @@ type TorrentInfo struct {
|
||||
Hash string `json:"hash"`
|
||||
Progress int `json:"-"`
|
||||
Status string `json:"status"`
|
||||
Added string `json:"added"`
|
||||
Ended string `json:"ended"`
|
||||
Added string `json:"-"`
|
||||
Ended string `json:"-"`
|
||||
Bytes int64 `json:"bytes"`
|
||||
Links []string `json:"links"`
|
||||
OriginalName string `json:"original_filename"` // from info
|
||||
OriginalBytes int64 `json:"original_bytes"` // from info
|
||||
Files []File `json:"files"` // from info
|
||||
OriginalName string `json:"original_filename"`
|
||||
OriginalBytes int64 `json:"original_bytes"`
|
||||
Files []File `json:"files"`
|
||||
Version string `json:"-"`
|
||||
}
|
||||
|
||||
@@ -66,6 +64,8 @@ func (i *TorrentInfo) UnmarshalJSON(data []byte) error {
|
||||
type Alias TorrentInfo
|
||||
aux := &struct {
|
||||
Progress float64 `json:"progress"`
|
||||
Added string `json:"added"`
|
||||
Ended string `json:"ended"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(i),
|
||||
@@ -76,6 +76,13 @@ func (i *TorrentInfo) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
i.Progress = int(math.Round(aux.Progress))
|
||||
|
||||
i.Added = strings.Replace(aux.Added, "Z", "+01:00", 1)
|
||||
|
||||
if aux.Ended != "" {
|
||||
i.Ended = strings.Replace(aux.Ended, "Z", "+01:00", 1)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user