delugeclient

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 2

README

delugeclient

Simple Deluge client for Go

Features

  • Add mangnet link
  • Get list of all torrents in the server
  • Remove a torrent

Usage

    import "github.com/adelolmo/delugeclient"

    // Connect to Deluge server
    deluge := delugeclient.NewDeluge("deluge_server_url", "deluge_password")
    if err := deluge.Connect(); err != nil {
        panic(err)
    }

    // Add a magnet link
    if err := deluge.AddMagnet("magnet:?xt=urn:btih:032f37e3b98f60148a6..."); err != nil {
        panic(err)
    }

    // List all elements in the server
    torrents, err := deluge.GetAll()
    if err != nil {
        panic(err)
    }
    for _, t := range torrents {
        fmt.Printf("%s,%s,%f,%f\n", t.Id, t.Name, t.Progress, t.ShareRatio)
    }

    // Remove a single element
    if err = deluge.Remove("f7647dfb2e9d..."); err != nil {
        panic(err)
    }

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllResponse

type AllResponse struct {
	Index    int        `json:"id"`
	Torrents TorrentSet `json:"result"`
	Error    RpcError   `json:"error"`
}

type Deluge

type Deluge struct {
	ServiceUrl string
	Password   string
	Index      int
	HttpClient http.Client
}

func NewDeluge

func NewDeluge(serverUrl, password string) *Deluge

NewDeluge initializes the client

func (*Deluge) AddMagnet

func (d *Deluge) AddMagnet(magnet string) error

AddMagnet adds a magnet/torrent link

func (*Deluge) Connect

func (d *Deluge) Connect() error

Connect establishes a connection to the server

func (*Deluge) Get

func (d *Deluge) Get(torrentId string) (*Torrent, error)

Get the link details about a single link given its hash id (torrentId)

func (*Deluge) GetAll

func (d *Deluge) GetAll() ([]Torrent, error)

GetAll gets the link details off all entries

func (*Deluge) MoveToQueueTop

func (d *Deluge) MoveToQueueTop(torrentId string) error

MoveToQueueTop moves a torrent to the queue top

func (*Deluge) Remove

func (d *Deluge) Remove(torrentId string) error

Remove removes a link given its hash id (torrentId)

type Detail

type Detail struct {
	Path string `json:"path"`
}

type ResponseEntry added in v0.4.0

type ResponseEntry struct {
	HasValue bool
	Value    string
}

type RpcError

type RpcError struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

func (RpcError) String

func (e RpcError) String() string

type RpcResponse

type RpcResponse struct {
	Id     int      `json:"id"`
	Result bool     `json:"result"`
	Error  RpcError `json:"error"`
}

func (RpcResponse) String

func (r RpcResponse) String() string

type RpcResponseComplex added in v0.4.0

type RpcResponseComplex struct {
	Id     int             `json:"id"`
	Result [][]interface{} `json:"result"`
	Error  RpcError        `json:"error"`
}

type Torrent

type Torrent struct {
	Id         string
	Name       string
	Progress   float64
	ShareRatio float64
	Files      []string
}

func (*Torrent) String

func (t *Torrent) String() string

type TorrentContent

type TorrentContent struct {
	Index         int           `json:"id"`
	TorrentResult TorrentResult `json:"result"`
	Error         RpcError      `json:"error"`
}

type TorrentDetail

type TorrentDetail struct {
	Priority        int64                    `json:"priority"`
	Path            string                   `json:"path"`
	Type            string                   `json:"type"`
	ShareRatio      float64                  `json:"ratio"`
	Progress        float64                  `json:"progress"`
	TorrentEntryMap map[string]TorrentDetail `json:"contents"`
}

type TorrentEntry

type TorrentEntry struct {
	Message  string  `json:"message"`
	Progress float64 `json:"progress"`
	Ratio    float64 `json:"ratio"`
	Name     string  `json:"name"`
}

type TorrentResult

type TorrentResult struct {
	Type     string                   `json:"type"`
	Contents map[string]TorrentDetail `json:"contents"`
}

type TorrentSet

type TorrentSet struct {
	Map map[string]TorrentEntry `json:"torrents"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL