client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Registry      []*RegInfo = make([]*RegInfo, 0)
	PSEUDO_STATES            = []string{"_all", "_active", "_done"}
)

Functions

func ClientExists

func ClientExists(name string) bool

func GenerateNameWithMeta

func GenerateNameWithMeta(name string, meta map[string](int64)) string

func GenerateTorrentTagFromSite

func GenerateTorrentTagFromSite(site string) string

func GetClientTorrentInfoHashes

func GetClientTorrentInfoHashes(clientInstance Client, stateFilter string, category string) ([]string, error)

func ParseMetaFromName

func ParseMetaFromName(fullname string) (name string, meta map[string](int64))

func PrintTorrents

func PrintTorrents(torrents []Torrent, filter string)

func Register

func Register(regInfo *RegInfo)

func TorrentStateIconText

func TorrentStateIconText(torrent *Torrent) string

func XseedCheckTorrentContents

func XseedCheckTorrentContents(clientTorrentContents []TorrentContentFile, torrentContents []*goTorrentParser.File) int64

return 0 if equal; 1 if clientTorrentContents contains all files of torrentContents. -1 in other cases

Types

type Client

type Client interface {
	GetTorrent(infoHash string) (*Torrent, error)
	// stateFilter: _all|_active|_done, or any state value (possibly with a _ prefix)
	GetTorrents(stateFilter string, category string, showAll bool) ([]Torrent, error)
	AddTorrent(torrentContent []byte, option *TorrentOption, meta map[string](int64)) error
	ModifyTorrent(infoHash string, option *TorrentOption, meta map[string](int64)) error
	DeleteTorrents(infoHashes []string, deleteFiles bool) error
	PauseTorrents(infoHashes []string) error
	ResumeTorrents(infoHashes []string) error
	RecheckTorrents(infoHashes []string) error
	ReannounceTorrents(infoHashes []string) error
	PauseAllTorrents() error
	ResumeAllTorrents() error
	RecheckAllTorrents() error
	ReannounceAllTorrents() error
	GetTags() ([]string, error)
	CreateTags(tags ...string) error
	DeleteTags(tags ...string) error
	GetCategories() ([]string, error)
	SetTorrentsCatetory(infoHashes []string, category string) error
	SetAllTorrentsCatetory(category string) error
	TorrentRootPathExists(rootFolder string) bool
	GetTorrentContents(infoHash string) ([]TorrentContentFile, error)
	PurgeCache()
	GetStatus() (*Status, error)
	GetName() string
	GetClientConfig() *config.ClientConfigStruct
	SetConfig(variable string, value string) error
	GetConfig(variable string) (string, error)
}

func CreateClient

func CreateClient(name string) (Client, error)

type ClientCreator

type ClientCreator func(*RegInfo) (Client, error)

type RegInfo

type RegInfo struct {
	Name    string
	Creator func(string, *config.ClientConfigStruct, *config.ConfigStruct) (Client, error)
}

func Find

func Find(name string) (*RegInfo, error)

type Status

type Status struct {
	FreeSpaceOnDisk    int64 // -1 means unknown / unlimited
	DownloadSpeed      int64
	UploadSpeed        int64
	DownloadSpeedLimit int64 // <= 0 means no limit
	UploadSpeedLimit   int64 // <= 0 means no limit
	NoAdd              bool  // if true, brush and other tasks will NOT add any torrents to client
}

type Torrent

type Torrent struct {
	InfoHash           string
	Name               string
	TrackerDomain      string
	State              string // simplified state: seeding|downloading|completed|paused|checking|<any others>...
	LowLevelState      string // original state value returned by bt client
	Atime              int64  // timestamp torrent added
	Ctime              int64  // timestamp torrent completed. <=0 if not completed.
	Category           string
	SavePath           string
	Tags               []string
	Downloaded         int64
	DownloadSpeed      int64
	DownloadSpeedLimit int64 // -1 means no limit
	Uploaded           int64
	UploadSpeed        int64
	UploadedSpeedLimit int64 // -1 means no limit
	Size               int64 // size of torrent files that selected for downloading
	SizeTotal          int64 // Total size of all file in the torrent (including unselected ones)
	SizeCompleted      int64
	Seeders            int64
	Leechers           int64
	Meta               map[string](int64)
}

func (*Torrent) GetSiteFromTag

func (torrent *Torrent) GetSiteFromTag() string

func (*Torrent) HasTag

func (torrent *Torrent) HasTag(tag string) bool

func (*Torrent) IsComplete

func (torrent *Torrent) IsComplete() bool

func (*Torrent) IsFull

func (torrent *Torrent) IsFull() bool

func (*Torrent) IsFullComplete

func (torrent *Torrent) IsFullComplete() bool

type TorrentContentFile

type TorrentContentFile struct {
	Index    int64
	Path     string // full file path
	Size     int64
	Complete bool // true if file is fullly downloaded
}

type TorrentOption

type TorrentOption struct {
	Name               string
	Category           string
	SavePath           string
	Tags               []string
	RemoveTags         []string // used only in ModifyTorrent
	DownloadSpeedLimit int64
	UploadSpeedLimit   int64
	SkipChecking       bool
	Pause              bool
	Resume             bool // use only in ModifyTorrent, to start a paused torrent
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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