Small repairs on logic

This commit is contained in:
Ben Adrian Sarmiento
2024-06-18 19:32:56 +02:00
parent d53ba8c973
commit 34a7d6a432
8 changed files with 78 additions and 74 deletions

View File

@@ -68,6 +68,20 @@ func (i *Torrent) UnmarshalJSON(data []byte) error {
return nil
}
func (i *Torrent) MarshalJSON() ([]byte, error) {
type Alias Torrent
aux := &struct {
Progress float64 `json:"progress"`
Added string `json:"added"`
*Alias
}{
Alias: (*Alias)(i),
Progress: float64(i.Progress), // Convert int to float64 for JSON representation
Added: i.Added,
}
return json.Marshal(aux)
}
type TorrentInfo struct {
ID string `json:"id"`
Name string `json:"filename"`