Fix the float64 conversion
This commit is contained in:
@@ -283,19 +283,19 @@ func (t *TorrentManager) addMoreInfo(torrent *Torrent) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if len(selectedFiles) > len(info.Links) && info.Progress == 100 {
|
if len(selectedFiles) > len(info.Links) && info.Progress == 100 {
|
||||||
log.Printf("Some links has expired for %s, %s: %d selected but only %d links\n", info.ID, info.Name, len(selectedFiles), len(info.Links))
|
log.Printf("Some links has expired for %s, %s: %d selected but only %d link(s)\n", info.ID, info.Name, len(selectedFiles), len(info.Links))
|
||||||
// chaotic file means RD will not output the desired file selection
|
// chaotic file means RD will not output the desired file selection
|
||||||
// e.g. even if we select just a single mkv, it will output a rar
|
// e.g. even if we select just a single mkv, it will output a rar
|
||||||
var isChaotic bool
|
var isChaotic bool
|
||||||
selectedFiles, isChaotic = t.organizeChaos(info, selectedFiles)
|
selectedFiles, isChaotic = t.organizeChaos(info, selectedFiles)
|
||||||
if isChaotic {
|
if isChaotic {
|
||||||
log.Println("This torrent is unfixable, it's always returning an unstreamable link, ignoring", info.Name, info.ID)
|
log.Println("This torrent is unfixable, it's always returning an unstreamable link, ignoring", info.ID, info.Name)
|
||||||
} else {
|
} else {
|
||||||
if len(streamableFiles) > 1 {
|
if len(streamableFiles) > 1 {
|
||||||
log.Println("Marking for repair", info.Name)
|
log.Println("Marking for repair", info.ID, info.Name)
|
||||||
forRepair = true
|
forRepair = true
|
||||||
} else {
|
} else {
|
||||||
log.Println("This torrent is unfixable, the lone streamable link has expired, ignoring", info.Name, info.ID)
|
log.Println("This torrent is unfixable, the lone streamable link has expired, ignoring", info.ID, info.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package realdebrid
|
package realdebrid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"math"
|
||||||
|
)
|
||||||
|
|
||||||
type FileJSON struct {
|
type FileJSON struct {
|
||||||
FileSize int `json:"filesize"`
|
FileSize int `json:"filesize"`
|
||||||
Link string `json:"link"`
|
Link string `json:"link"`
|
||||||
@@ -17,13 +22,30 @@ type Torrent struct {
|
|||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"filename"`
|
Name string `json:"filename"`
|
||||||
Hash string `json:"hash"`
|
Hash string `json:"hash"`
|
||||||
Progress int `json:"progress"`
|
Progress int `json:"-"`
|
||||||
Added string `json:"added"`
|
Added string `json:"added"`
|
||||||
Bytes int64 `json:"bytes"`
|
Bytes int64 `json:"bytes"`
|
||||||
Links []string `json:"links"`
|
Links []string `json:"links"`
|
||||||
Files []File `json:"files,omitempty"`
|
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 {
|
type File struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
|
|||||||
Reference in New Issue
Block a user