NullpointerW / go-qbittorrent-apiv2

qBittorrent web API(v2.8.3) wrapper for go
MIT License
3 stars 4 forks source link

New Tracker Struct (tested on qB4.6.4) #6

Open ludoux opened 6 days ago

ludoux commented 6 days ago

https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-trackers

https://github.com/NullpointerW/go-qbittorrent-apiv2/blob/9b515d3fcfaf4f8e951a48d100d055cbda590f6c/torrents.go#L108-L113

// Tracker holds a tracker object from qbittorrent
type Tracker struct {
    Msg           string `json:"msg"`
    NumDownloaded int    `json:"num_downloaded"`
    NumLeeches    int    `json:"num_leeches"`
    NumPeers      int    `json:"num_peers"`
    NumSeeds      int    `json:"num_seeds"`
    Status        int    `json:"status"`
    Tier          int    `json:"tier"`
    URL           string `json:"url"`
}
func (c *Client) GetTrackersByHash(hash string) ([]Tracker, error) {
    opt := Optional{
        "hash": hash,
    }
    resp, err := c.postXwwwFormUrlencoded("torrents/trackers", opt)
    err = RespOk(resp, err)
    if err != nil {
        return nil, err
    }
    defer resp.Body.Close()
    b, err := io.ReadAll(resp.Body)
    if err != nil {
        return nil, err
    }
    tf := new([]Tracker)
    err = json.Unmarshal(b, tf)
    if err != nil {
        return nil, err
    }
    return *tf, nil
}
NullpointerW commented 4 days ago

Thanks,you can submit a PR,so we can merge those codes.

ludoux commented 4 days ago

Ok, I may create it in the future after arranging it.


发件人: NullpointerW @.> 发送时间: 2024年7月4日 23:39 收件人: NullpointerW/go-qbittorrent-apiv2 @.> 抄送: Lu Chang @.>; Author @.> 主题: Re: [NullpointerW/go-qbittorrent-apiv2] New Tracker Struct (tested on qB4.6.4) (Issue #6)

Thanks,you can submit a PR,so we can merge those codes.

― Reply to this email directly, view it on GitHubhttps://github.com/NullpointerW/go-qbittorrent-apiv2/issues/6#issuecomment-2209252766, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADGWKTANH5GIOCSALEBDDPDZKVUERAVCNFSM6AAAAABKHT2W3GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBZGI2TENZWGY. You are receiving this because you authored the thread.