delugeclient

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2019 License: GPL-2.0 Imports: 13 Imported by: 0

README

go-libdeluge

Go library for native RPC connection to a Deluge daemon; it uses go-rencode for the RPC protocol serialization/deserialization.

Release blog post.

License

GNU GPL version 2

How to build

This project uses an automatically-provisioned GOPATH. Example init/building commands on a Linux system:

git submodule update --init --recursive
make

How to use

The library by itself is a Go package and needs to be embedded in an UI or CLI application. An example CLI application is available through:

go get github.com/gdm85/go-libdeluge/delugecli

Example usage:

DELUGE_PASSWORD="mypassword" bin/delugecli -add magnet:?xt=urn:btih:C1939CA413B9AFCC34EA0CF3C128574E93FF6CB0&tr=http%3A%2F%2Ftorrent.ubuntu.com%3A6969%2Fannounce

This will start downloading the latest Ubuntu 14.04 LTS server ISO. Multiple magnet URIs are supported as command-line arguments; run bin/delugecli alone to see all available options and their description.

Documentation

Overview

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Index

Constants

View Source
const (
	DefaultReadWriteTimeout = time.Second * 30
)

Variables

View Source
var (
	// ErrAlreadyClosed is returned when connection is already closed.
	ErrAlreadyClosed      = errors.New("connection is already closed")
	ErrInvalidListResult  = errors.New("expected dictionary as list response")
	ErrInvalidReturnValue = errors.New("invalid return value")
)
View Source
var STATUS_KEYS = rencode.NewList(
	"state",
	"download_location",
	"tracker_host",
	"tracker_status",
	"next_announce",
	"name",
	"total_size",
	"progress",
	"num_seeds",
	"total_seeds",
	"num_peers",
	"total_peers",
	"eta",
	"download_payload_rate",
	"upload_payload_rate",
	"ratio",
	"distributed_copies",
	"num_pieces",
	"piece_length",
	"total_done",
	"files",
	"file_priorities",
	"file_progress",
	"peers",
	"is_seed",
	"is_finished",
	"active_time",
	"seeding_time")

Functions

This section is empty.

Types

type Client

type Client struct {
	DebugIncoming [][]byte
	// contains filtered or unexported fields
}

Client is a Deluge RPC client.

func New

func New(s Settings) *Client

New returns a Deluge client.

func (*Client) AddTorrentFile added in v0.3.1

func (c *Client) AddTorrentFile(fileName, fileContentBase64 string, options Options) (string, error)

func (*Client) AddTorrentMagnet

func (c *Client) AddTorrentMagnet(magnetURI string, options Options) (string, error)

AddTorrentMagnet adds a torrent via magnet URI and returns the torrent hash.

func (*Client) AddTorrentURL added in v0.3.1

func (c *Client) AddTorrentURL(url string, options Options) (string, error)

AddTorrentURL adds a torrent via a URL and returns the torrent hash.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection of a Deluge client.

func (*Client) Connect

func (c *Client) Connect() error

Connect performs connection to a Deluge daemon second previously specified settings.

func (*Client) DaemonVersion

func (c *Client) DaemonVersion() (string, error)

DaemonVersion returns the running daemon version.

func (*Client) DeleteTorrent added in v0.3.1

func (c *Client) DeleteTorrent(id string) (bool, error)

func (*Client) GetFreeSpace added in v0.3.1

func (c *Client) GetFreeSpace(path string) (int64, error)

GetFreeSpace returns the available free space; path is optional.

func (*Client) MethodsList

func (c *Client) MethodsList() ([]string, error)

MethodsList returns a list of available methods on server.

func (*Client) MoveStorage added in v0.3.1

func (c *Client) MoveStorage(torrentIDs []string, dest string) error

func (*Client) SessionState added in v0.3.1

func (c *Client) SessionState() ([]string, error)

func (*Client) TorrentsStatus added in v0.3.1

func (c *Client) TorrentsStatus() (map[string]*TorrentStatus, error)

type DelugeClient added in v0.3.1

type DelugeClient interface {
	MethodsList() ([]string, error)
	DaemonVersion() (string, error)
	GetFreeSpace(string) (int64, error)
	AddTorrentMagnet(magnetURI string, options Options) (string, error)
	AddTorrentFile(fileName, fileContentBase64 string, options Options) (string, error)
	AddTorrentURL(url string, options Options) (string, error)
	DeleteTorrent(id string) (bool, error)
	TorrentsStatus() (map[string]*TorrentStatus, error)
	MoveStorage(torrentIDs []string, dest string) error
	SessionState() ([]string, error)
}

type DelugeResponse

type DelugeResponse struct {

	// only in rpcError
	RPCError
	// contains filtered or unexported fields
}

DelugeResponse is a response returned from a completed RPC call.

func (*DelugeResponse) IsError

func (dr *DelugeResponse) IsError() bool

IsError returns true when the response is an error.

func (*DelugeResponse) String

func (dr *DelugeResponse) String() string

type File added in v0.3.1

type File struct {
	Index  int64
	Size   int64
	Offset int64
	Path   string
}

type NativeDelugeClient added in v0.3.1

type NativeDelugeClient interface {
	Close() error
	Connect() error
}

type Options added in v0.3.1

type Options map[string]interface{}

Options used when adding a torrent magnet/URL

type Peer added in v0.3.1

type Peer struct {
	Client    string
	IP        string
	Progress  float32
	Seed      int64
	DownSpeed int64
	UpSpeed   int64
	Country   string
}

type RPCError

type RPCError struct {
	ExceptionType    string
	ExceptionMessage string
	TraceBack        string
}

RPCError is an error returned by RPC calls.

func (RPCError) Error

func (e RPCError) Error() string

type SerialMismatchError added in v0.3.1

type SerialMismatchError struct {
	ExpectedID int64
	ReceivedID int64
}

func (SerialMismatchError) Error added in v0.3.1

func (e SerialMismatchError) Error() string

type Settings

type Settings struct {
	Hostname              string
	Port                  uint
	Login                 string
	Password              string
	Logger                *log.Logger
	ReadWriteTimeout      time.Duration // Timeout for read/write operations on the TCP stream.
	DebugSaveInteractions bool
}

Settings defines all settings for a Deluge client connection.

type TorrentStatus added in v0.3.1

type TorrentStatus struct {
	NumSeeds            int64
	Ratio               float32
	Progress            float32 // max is 100
	DistributedCopies   float32
	TotalDone           int64
	SeedingTime         int64
	ETA                 float32 // most times an integer
	IsFinished          bool
	NumPieces           int64
	TrackerHost         string
	PieceLength         int64
	ActiveTime          int64
	IsSeed              bool
	NumPeers            int64
	NextAnnounce        int64
	Name                string
	State               string
	TotalSeeds          int64
	TotalPeers          int64
	DownloadPayloadRate int64
	UploadPayloadRate   int64
	TrackerStatus       string
	TotalSize           int64

	Files          []File
	Peers          []Peer
	FilePriorities []int64
	FileProgress   []float32
}

Directories

Path Synopsis
* go-libdeluge v0.2.0 - a native deluge RPC client library * Copyright (C) 2015~2017 gdm85 - https://github.com/gdm85/go-libdeluge/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
* go-libdeluge v0.2.0 - a native deluge RPC client library * Copyright (C) 2015~2017 gdm85 - https://github.com/gdm85/go-libdeluge/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Jump to

Keyboard shortcuts

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