parent
0bc6227427
commit
80884aca6a
14 changed files with 299 additions and 155 deletions
pkg/qbittorrent
|
@ -62,7 +62,7 @@ type Torrent interface {
|
|||
// MinPriority minimal torrent priority
|
||||
MinPriority(ctx context.Context, hashes []string) error
|
||||
// SetFilePriority set file priority
|
||||
SetFilePriority(ctx context.Context, hash string, id string, priority int) error
|
||||
SetFilePriority(ctx context.Context, hash string, id int, priority Priority) error
|
||||
// GetDownloadLimit get torrent download limit
|
||||
GetDownloadLimit(ctx context.Context, hashes []string) (map[string]int, error)
|
||||
// SetDownloadLimit set torrent download limit, limit in bytes per second, if no limit please set value zero
|
||||
|
@ -273,15 +273,24 @@ type TorrentWebSeed struct {
|
|||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
type Priority int
|
||||
|
||||
const (
|
||||
PriorityDoNotDownload Priority = 0
|
||||
PriorityNormal Priority = 1
|
||||
PriorityHigh Priority = 6
|
||||
PriorityMax Priority = 7
|
||||
)
|
||||
|
||||
type TorrentContent struct {
|
||||
Availability float64 `json:"availability,omitempty"`
|
||||
Index int `json:"index,omitempty"`
|
||||
IsSeed bool `json:"is_seed,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
PieceRange []int `json:"piece_range,omitempty"`
|
||||
Priority int `json:"priority,omitempty"`
|
||||
Progress float64 `json:"progress,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
Availability float64 `json:"availability,omitempty"`
|
||||
Index int `json:"index,omitempty"`
|
||||
IsSeed bool `json:"is_seed,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
PieceRange []int `json:"piece_range,omitempty"`
|
||||
Priority Priority `json:"priority,omitempty"`
|
||||
Progress float64 `json:"progress,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
}
|
||||
|
||||
type TorrentAddFileMetadata struct {
|
||||
|
@ -929,14 +938,14 @@ func (c *client) MinPriority(ctx context.Context, hashes []string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *client) SetFilePriority(ctx context.Context, hash string, id string, priority int) error {
|
||||
func (c *client) SetFilePriority(ctx context.Context, hash string, id int, priority Priority) error {
|
||||
ctx, span := trace.Start(ctx, "qbittorrent.Torrent.SetFilePriority")
|
||||
defer span.End()
|
||||
|
||||
var formData = url.Values{}
|
||||
formData.Add("hash", hash)
|
||||
formData.Add("id", id)
|
||||
formData.Add("priority", strconv.Itoa(priority))
|
||||
formData.Add("id", strconv.Itoa(id))
|
||||
formData.Add("priority", strconv.Itoa(int(priority)))
|
||||
var apiUrl = fmt.Sprintf("%s/api/v2/torrents/filePrio", c.config.Address)
|
||||
result, err := c.doRequest(ctx, &requestData{
|
||||
url: apiUrl,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue