qbittorrent

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 17 Imported by: 2

README

go-qbittorrent

Go library for communicating with qBittorrent.

Documentation

Index

Constants

View Source
const (
	ConnectionStatusConnected    = "connected"
	ConnectionStatusFirewalled   = "firewalled"
	ConnectionStatusDisconnected = "disconnected"
)
View Source
const (
	ReannounceMaxAttempts = 50
	ReannounceInterval    = 7000
)

Variables

View Source
var (
	DefaultTimeout = 60 * time.Second
)

Functions

This section is empty.

Types

type Category

type Category struct {
	Name     string `json:"name"`
	SavePath string `json:"savePath"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg Config) *Client

func (*Client) AddTorrentFromFile

func (c *Client) AddTorrentFromFile(filePath string, options map[string]string) error

AddTorrentFromFile add new torrent from torrent file

func (*Client) AddTorrentFromFileCtx

func (c *Client) AddTorrentFromFileCtx(ctx context.Context, filePath string, options map[string]string) error

func (*Client) AddTorrentFromUrl

func (c *Client) AddTorrentFromUrl(url string, options map[string]string) error

AddTorrentFromUrl add new torrent from torrent file

func (*Client) AddTorrentFromUrlCtx

func (c *Client) AddTorrentFromUrlCtx(ctx context.Context, url string, options map[string]string) error

func (*Client) CreateCategory

func (c *Client) CreateCategory(category string, path string) error

func (*Client) CreateCategoryCtx

func (c *Client) CreateCategoryCtx(ctx context.Context, category string, path string) error

func (*Client) DeleteTorrents

func (c *Client) DeleteTorrents(hashes []string, deleteFiles bool) error

func (*Client) DeleteTorrentsCtx

func (c *Client) DeleteTorrentsCtx(ctx context.Context, hashes []string, deleteFiles bool) error

func (*Client) EditCategory

func (c *Client) EditCategory(category string, path string) error

func (*Client) EditCategoryCtx

func (c *Client) EditCategoryCtx(ctx context.Context, category string, path string) error

func (*Client) GetCategories

func (c *Client) GetCategories() (map[string]Category, error)

func (*Client) GetCategoriesCtx

func (c *Client) GetCategoriesCtx(ctx context.Context) (map[string]Category, error)

func (*Client) GetFilesInformation

func (c *Client) GetFilesInformation(hash string) (*TorrentFiles, error)

func (*Client) GetFilesInformationCtx

func (c *Client) GetFilesInformationCtx(ctx context.Context, hash string) (*TorrentFiles, error)

func (*Client) GetTorrentTrackers

func (c *Client) GetTorrentTrackers(hash string) ([]TorrentTracker, error)

func (*Client) GetTorrentTrackersCtx

func (c *Client) GetTorrentTrackersCtx(ctx context.Context, hash string) ([]TorrentTracker, error)

func (*Client) GetTorrents

func (c *Client) GetTorrents(o TorrentFilterOptions) ([]Torrent, error)

func (*Client) GetTorrentsActiveDownloads

func (c *Client) GetTorrentsActiveDownloads() ([]Torrent, error)

func (*Client) GetTorrentsActiveDownloadsCtx

func (c *Client) GetTorrentsActiveDownloadsCtx(ctx context.Context) ([]Torrent, error)

func (*Client) GetTorrentsCtx

func (c *Client) GetTorrentsCtx(ctx context.Context, o TorrentFilterOptions) ([]Torrent, error)

func (*Client) GetTorrentsRaw

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

func (*Client) GetTorrentsRawCtx

func (c *Client) GetTorrentsRawCtx(ctx context.Context) (string, error)

func (*Client) GetTransferInfo

func (c *Client) GetTransferInfo() (*TransferInfo, error)

func (*Client) GetTransferInfoCtx

func (c *Client) GetTransferInfoCtx(ctx context.Context) (*TransferInfo, error)

func (*Client) LoginCtx

func (c *Client) LoginCtx(ctx context.Context) error

func (*Client) Pause

func (c *Client) Pause(hashes []string) error

func (*Client) PauseCtx

func (c *Client) PauseCtx(ctx context.Context, hashes []string) error

func (*Client) ReAnnounceTorrents

func (c *Client) ReAnnounceTorrents(hashes []string) error

func (*Client) ReAnnounceTorrentsCtx

func (c *Client) ReAnnounceTorrentsCtx(ctx context.Context, hashes []string) error

func (*Client) ReannounceTorrentWithRetry added in v1.1.0

func (c *Client) ReannounceTorrentWithRetry(ctx context.Context, opts ReannounceOptions, hash string) error

func (*Client) Recheck

func (c *Client) Recheck(hashes []string) error

func (*Client) RecheckCtx

func (c *Client) RecheckCtx(ctx context.Context, hashes []string) error

func (*Client) RemoveCategories

func (c *Client) RemoveCategories(categories []string) error

func (*Client) RemoveCategoriesCtx

func (c *Client) RemoveCategoriesCtx(ctx context.Context, categories []string) error

func (*Client) RenameFile

func (c *Client) RenameFile(hash, oldPath, newPath string) error

func (*Client) RenameFileCtx

func (c *Client) RenameFileCtx(ctx context.Context, hash, oldPath, newPath string) error

func (*Client) Resume

func (c *Client) Resume(hashes []string) error

func (*Client) ResumeCtx

func (c *Client) ResumeCtx(ctx context.Context, hashes []string) error

func (*Client) SetAutoManagement

func (c *Client) SetAutoManagement(hashes []string, enable bool) error

func (*Client) SetAutoManagementCtx

func (c *Client) SetAutoManagementCtx(ctx context.Context, hashes []string, enable bool) error

func (*Client) SetCategory

func (c *Client) SetCategory(hashes []string, category string) error

func (*Client) SetCategoryCtx

func (c *Client) SetCategoryCtx(ctx context.Context, hashes []string, category string) error

func (*Client) SetForceStart

func (c *Client) SetForceStart(hashes []string, value bool) error

func (*Client) SetForceStartCtx

func (c *Client) SetForceStartCtx(ctx context.Context, hashes []string, value bool) error

func (*Client) SetLocation

func (c *Client) SetLocation(hashes []string, location string) error

func (*Client) SetLocationCtx

func (c *Client) SetLocationCtx(ctx context.Context, hashes []string, location string) error

type Config

type Config struct {
	Host     string
	Username string
	Password string

	// TLS skip cert validation
	TLSSkipVerify bool

	// HTTP Basic auth username
	BasicUser string

	// HTTP Basic auth password
	BasicPass string

	Timeout int
	Log     *log.Logger
}

type ConnectionStatus

type ConnectionStatus string

type ContentLayout

type ContentLayout string
const (
	ContentLayoutOriginal        ContentLayout = "Original"
	ContentLayoutSubfolderNone   ContentLayout = "NoSubfolder"
	ContentLayoutSubfolderCreate ContentLayout = "Subfolder"
)

type ReannounceOptions added in v1.1.0

type ReannounceOptions struct {
	Interval        int
	MaxAttempts     int
	DeleteOnFailure bool
}

type Torrent

type Torrent struct {
	AddedOn            int          `json:"added_on"`
	AmountLeft         int          `json:"amount_left"`
	AutoManaged        bool         `json:"auto_tmm"`
	Availability       float32      `json:"availability"`
	Category           string       `json:"category"`
	Completed          int          `json:"completed"`
	CompletionOn       int          `json:"completion_on"`
	DlLimit            int          `json:"dl_limit"`
	DlSpeed            int          `json:"dl_speed"`
	Downloaded         int          `json:"downloaded"`
	DownloadedSession  int          `json:"downloaded_session"`
	ETA                int          `json:"eta"`
	FirstLastPiecePrio bool         `json:"f_l_piece_prio"`
	ForceStart         bool         `json:"force_start"`
	Hash               string       `json:"hash"`
	LastActivity       int          `json:"last_activity"`
	MagnetURI          string       `json:"magnet_uri"`
	MaxRatio           float32      `json:"max_ratio"`
	MaxSeedingTime     int          `json:"max_seeding_time"`
	Name               string       `json:"name"`
	NumComplete        int          `json:"num_complete"`
	NumIncomplete      int          `json:"num_incomplete"`
	NumSeeds           int          `json:"num_seeds"`
	Priority           int          `json:"priority"`
	Progress           float32      `json:"progress"`
	Ratio              float32      `json:"ratio"`
	RatioLimit         float32      `json:"ratio_limit"`
	SavePath           string       `json:"save_path"`
	SeedingTimeLimit   int          `json:"seeding_time_limit"`
	SeenComplete       int          `json:"seen_complete"`
	SequentialDownload bool         `json:"seq_dl"`
	Size               int          `json:"size"`
	State              TorrentState `json:"state"`
	SuperSeeding       bool         `json:"super_seeding"`
	Tags               string       `json:"tags"`
	TimeActive         int          `json:"time_active"`
	TotalSize          int          `json:"total_size"`
	Tracker            *string      `json:"tracker"`
	UpLimit            int          `json:"up_limit"`
	Uploaded           int          `json:"uploaded"`
	UploadedSession    int          `json:"uploaded_session"`
	UpSpeed            int          `json:"upspeed"`
}

type TorrentAddOptions

type TorrentAddOptions struct {
	Paused             bool
	SkipHashCheck      bool
	ContentLayout      ContentLayout
	SavePath           string
	AutoTMM            bool
	Category           string
	Tags               string
	LimitUploadSpeed   int64
	LimitDownloadSpeed int64
	LimitRatio         float64
	LimitSeedTime      int64
}

func (*TorrentAddOptions) Prepare

func (o *TorrentAddOptions) Prepare() map[string]string

type TorrentFiles

type TorrentFiles []struct {
	Availability int     `json:"availability"`
	Index        int     `json:"index"`
	IsSeed       bool    `json:"is_seed,omitempty"`
	Name         string  `json:"name"`
	PieceRange   []int   `json:"piece_range"`
	Priority     int     `json:"priority"`
	Progress     float32 `json:"progress"`
	Size         int     `json:"size"`
}

type TorrentFilter

type TorrentFilter string
const (
	// Torrent is paused
	TorrentFilterAll TorrentFilter = "all"

	// Torrent is active
	TorrentFilterActive TorrentFilter = "active"

	// Torrent is inactive
	TorrentFilterInactive TorrentFilter = "inactive"

	// Torrent is completed
	TorrentFilterCompleted TorrentFilter = "completed"

	// Torrent is resumed
	TorrentFilterResumed TorrentFilter = "resumed"

	// Torrent is paused
	TorrentFilterPaused TorrentFilter = "paused"

	// Torrent is stalled
	TorrentFilterStalled TorrentFilter = "stalled"

	// Torrent is being seeded and data is being transferred
	TorrentFilterUploading TorrentFilter = "uploading"

	// Torrent is being seeded, but no connection were made
	TorrentFilterStalledUploading TorrentFilter = "stalled_uploading"

	// Torrent is being downloaded and data is being transferred
	TorrentFilterDownloading TorrentFilter = "downloading"

	// Torrent is being downloaded, but no connection were made
	TorrentFilterStalledDownloading TorrentFilter = "stalled_downloading"

	// Torrent is errored
	TorrentFilterError TorrentFilter = "errored"
)

type TorrentFilterOptions

type TorrentFilterOptions struct {
	Filter   TorrentFilter
	Category string
	Tag      string
	Sort     string
	Reverse  bool
	Limit    int
	Offset   int
	Hashes   []string
}

type TorrentState

type TorrentState string
const (
	// Some error occurred, applies to paused torrents
	TorrentStateError TorrentState = "error"

	// Torrent data files is missing
	TorrentStateMissingFiles TorrentState = "missingFiles"

	// Torrent is being seeded and data is being transferred
	TorrentStateUploading TorrentState = "uploading"

	// Torrent is paused and has finished downloading
	TorrentStatePausedUp TorrentState = "pausedUP"

	// Queuing is enabled and torrent is queued for upload
	TorrentStateQueuedUp TorrentState = "queuedUP"

	// Torrent is being seeded, but no connection were made
	TorrentStateStalledUp TorrentState = "stalledUP"

	// Torrent has finished downloading and is being checked
	TorrentStateCheckingUp TorrentState = "checkingUP"

	// Torrent is forced to uploading and ignore queue limit
	TorrentStateForcedUp TorrentState = "forcedUP"

	// Torrent is allocating disk space for download
	TorrentStateAllocating TorrentState = "allocating"

	// Torrent is being downloaded and data is being transferred
	TorrentStateDownloading TorrentState = "downloading"

	// Torrent has just started downloading and is fetching metadata
	TorrentStateMetaDl TorrentState = "metaDL"

	// Torrent is paused and has NOT finished downloading
	TorrentStatePausedDl TorrentState = "pausedDL"

	// Queuing is enabled and torrent is queued for download
	TorrentStateQueuedDl TorrentState = "queuedDL"

	// Torrent is being downloaded, but no connection were made
	TorrentStateStalledDl TorrentState = "stalledDL"

	// Same as checkingUP, but torrent has NOT finished downloading
	TorrentStateCheckingDl TorrentState = "checkingDL"

	// Torrent is forced to downloading to ignore queue limit
	TorrentStateForcedDl TorrentState = "forcedDL"

	// Checking resume data on qBt startup
	TorrentStateCheckingResumeData TorrentState = "checkingResumeData"

	// Torrent is moving to another location
	TorrentStateMoving TorrentState = "moving"

	// Unknown status
	TorrentStateUnknown TorrentState = "unknown"
)

type TorrentTracker

type TorrentTracker struct {
	//Tier          int   `json:"tier"` // can be both empty "" and int
	Url           string        `json:"url"`
	Status        TrackerStatus `json:"status"`
	NumPeers      int           `json:"num_peers"`
	NumSeeds      int           `json:"num_seeds"`
	NumLeechers   int           `json:"num_leechers"`
	NumDownloaded int           `json:"num_downloaded"`
	Message       string        `json:"msg"`
}

type TorrentTrackersResponse

type TorrentTrackersResponse struct {
	Trackers []TorrentTracker `json:"trackers"`
}

type TrackerStatus

type TrackerStatus int

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

const (
	// 0 Tracker is disabled (used for DHT, PeX, and LSD)
	TrackerStatusDisabled TrackerStatus = 0

	// 1 Tracker has not been contacted yet
	TrackerStatusNotContacted TrackerStatus = 1

	// 2 Tracker has been contacted and is working
	TrackerStatusOK TrackerStatus = 2

	// 3 Tracker is updating
	TrackerStatusUpdating TrackerStatus = 3

	// 4 Tracker has been contacted, but it is not working (or doesn't send proper replies)
	TrackerStatusNotWorking TrackerStatus = 4
)

type TransferInfo

type TransferInfo struct {
	ConnectionStatus ConnectionStatus `json:"connection_status"`
	DHTNodes         int64            `json:"dht_nodes"`
	DlInfoData       int64            `json:"dl_info_data"`
	DlInfoSpeed      int64            `json:"dl_info_speed"`
	DlRateLimit      int64            `json:"dl_rate_limit"`
	UpInfoData       int64            `json:"up_info_data"`
	UpInfoSpeed      int64            `json:"up_info_speed"`
	UpRateLimit      int64            `json:"up_rate_limit"`
}

TransferInfo

https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-global-transfer-info

dl_info_speed integer Global download rate (bytes/s)

dl_info_data integer Data downloaded this session (bytes)

up_info_speed integer Global upload rate (bytes/s)

up_info_data integer Data uploaded this session (bytes)

dl_rate_limit integer Download rate limit (bytes/s)

up_rate_limit integer Upload rate limit (bytes/s)

dht_nodes integer DHT nodes connected to

connection_status string Connection status. See possible values here below

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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