qbittorrent

package
v1.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 60

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(s Settings) *Client

func (*Client) AddTorrentFromFile

func (c *Client) AddTorrentFromFile(ctx context.Context, file string, options map[string]string) (hash string, err error)

AddTorrentFromFile add new torrent from torrent file

func (*Client) AddTorrentFromMagnet

func (c *Client) AddTorrentFromMagnet(ctx context.Context, magnetUri string, options map[string]string) (hash string, err error)

func (*Client) DeleteTorrents

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

func (*Client) GetTorrentTrackers

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

func (*Client) GetTorrents

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

func (*Client) GetTorrentsByPrefixes

func (c *Client) GetTorrentsByPrefixes(ctx context.Context, terms []string, hashes bool, names bool) ([]Torrent, error)

GetTorrentsByPrefixes Search for torrents using provided prefixes; checks against either hashes, names, or both

func (*Client) GetTorrentsRaw

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

func (*Client) GetTorrentsWithFilters

func (c *Client) GetTorrentsWithFilters(ctx context.Context, req *GetTorrentsRequest) ([]Torrent, error)

func (*Client) Login

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

func (*Client) Pause

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

func (*Client) ReAnnounceTorrents

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

func (*Client) Resume

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

func (*Client) SetCategory

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

func (*Client) SetTag

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

type Fastresume

type Fastresume struct {
	ActiveTime                int64                  `bencode:"active_time"`
	AddedTime                 int64                  `bencode:"added_time"`
	Allocation                string                 `bencode:"allocation"`
	ApplyIpFilter             int64                  `bencode:"apply_ip_filter"`
	AnnounceToDht             int64                  `bencode:"announce_to_dht,omitempty"`
	AnnounceToLsd             int64                  `bencode:"announce_to_lsd,omitempty"`
	AnnounceToTrackers        int64                  `bencode:"announce_to_trackers,omitempty"`
	AutoManaged               int64                  `bencode:"auto_managed"`
	CompletedTime             int64                  `bencode:"completed_time"`
	DisableDHT                int64                  `bencode:"disable_dht"`
	DisableLSD                int64                  `bencode:"disable_lsd"`
	DisablePEX                int64                  `bencode:"disable_pex"`
	DownloadRateLimit         int64                  `bencode:"download_rate_limit"`
	FileFormat                string                 `bencode:"file-format"`
	FileVersion               int64                  `bencode:"file-version"`
	FilePriority              []int                  `bencode:"file_priority"`
	FileSizes                 [][]int64              `bencode:"file sizes,omitempty"`
	FinishedTime              int64                  `bencode:"finished_time"`
	HttpSeeds                 []string               `bencode:"httpseeds"`
	InfoHash                  []byte                 `bencode:"info-hash"`
	LastDownload              int64                  `bencode:"last_download"`
	LastSeenComplete          int64                  `bencode:"last_seen_complete"`
	LastUpload                int64                  `bencode:"last_upload"`
	LibTorrentVersion         string                 `bencode:"libtorrent-version"`
	MaxConnections            int64                  `bencode:"max_connections"`
	MaxUploads                int64                  `bencode:"max_uploads"`
	NumComplete               int64                  `bencode:"num_complete"`
	NumDownloaded             int64                  `bencode:"num_downloaded"`
	NumIncomplete             int64                  `bencode:"num_incomplete"`
	Paused                    int64                  `bencode:"paused"`
	Pieces                    string                 `bencode:"pieces"`
	PiecePriority             []byte                 `bencode:"piece_priority"`
	Peers                     string                 `bencode:"peers"`
	Peers6                    string                 `bencode:"peers6"`
	QbtCategory               string                 `bencode:"qBt-category"`
	QbtContentLayout          string                 `bencode:"qBt-contentLayout"`
	QbtHasRootFolder          int64                  `bencode:"qBt-hasRootFolder"`
	QbtFirstLastPiecePriority int64                  `bencode:"qBt-firstLastPiecePriority"`
	QbtName                   string                 `bencode:"qBt-name"`
	QbtRatioLimit             int64                  `bencode:"qBt-ratioLimit"`
	QbtSavePath               string                 `bencode:"qBt-savePath"`
	QbtSeedStatus             int64                  `bencode:"qBt-seedStatus"`
	QbtSeedingTimeLimit       int64                  `bencode:"qBt-seedingTimeLimit"`
	QbtTags                   []string               `bencode:"qBt-tags"`
	QbtQueuePosition          int                    `bencode:"qBt-queuePosition,omitempty"`
	QbtTempPathDisabled       int64                  `bencode:"qBt-tempPathDisabled,omitempty"`
	SavePath                  string                 `bencode:"save_path"`
	SeedMode                  int64                  `bencode:"seed_mode"`
	SeedingTime               int64                  `bencode:"seeding_time"`
	SequentialDownload        int64                  `bencode:"sequential_download"`
	ShareMode                 int64                  `bencode:"share_mode"`
	StopWhenReady             int64                  `bencode:"stop_when_ready"`
	SuperSeeding              int64                  `bencode:"super_seeding"`
	TotalDownloaded           int64                  `bencode:"total_downloaded"`
	TotalUploaded             int64                  `bencode:"total_uploaded"`
	Trackers                  [][]string             `bencode:"trackers"`
	UploadMode                int64                  `bencode:"upload_mode"`
	UploadRateLimit           int64                  `bencode:"upload_rate_limit"`
	UrlList                   []string               `bencode:"url-list"`
	Unfinished                *[]interface{}         `bencode:"unfinished,omitempty"`
	WithoutLabels             bool                   `bencode:"-"`
	WithoutTags               bool                   `bencode:"-"`
	HasFiles                  bool                   `bencode:"-"`
	TorrentFilePath           string                 `bencode:"-"`
	TorrentFile               map[string]interface{} `bencode:"-"`
	Path                      string                 `bencode:"-"`

	NumPieces   int64    `bencode:"-"`
	PieceLength int64    `bencode:"-"`
	MappedFiles []string `bencode:"mapped_files,omitempty"`
	// contains filtered or unexported fields
}

Fastresume represents a qBittorrent fastresume file

func (*Fastresume) ConvertFilePriority

func (fr *Fastresume) ConvertFilePriority(numFiles int)

ConvertFilePriority for each file set priority

func (*Fastresume) Encode

func (fr *Fastresume) Encode(path string) error

Encode qBittorrent fastresume file

func (*Fastresume) FillPieces

func (fr *Fastresume) FillPieces()

FillPieces set pieces as complete/done so fastresume doesn't recheck

func (*Fastresume) GetInfoHashSHA1

func (fr *Fastresume) GetInfoHashSHA1() (hash []byte)

GetInfoHashSHA1 returns a 20 byte hash

type GetTorrentsRequest

type GetTorrentsRequest struct {
	Filter   TorrentFilter
	Category string
	Tag      string
	Hashes   string
	Json     bool
}

type Settings

type Settings struct {
	Hostname      string
	Port          uint
	Addr          string
	Username      string
	Password      string
	BasicUser     string
	BasicPass     string
	TLSSkipVerify 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:"dlspeed"`
	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 TorrentBasic

type TorrentBasic struct {
	Category   string       `json:"category"`
	Downloaded int          `json:"downloaded"`
	Hash       string       `json:"hash"`
	Name       string       `json:"name"`
	Progress   float32      `json:"progress"`
	Ratio      float32      `json:"ratio"`
	Size       int          `json:"size"`
	State      TorrentState `json:"state"`
	Tags       string       `json:"tags"`
	Tracker    string       `json:"tracker"`
	Uploaded   int          `json:"uploaded"`
}

type TorrentFilter

type TorrentFilter string

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

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 seeding
	TorrentFilterSeeding TorrentFilter = "seeding"

	// 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"

	TorrentFilterErrored TorrentFilter = "errored"
)

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
	TorrentStateForceDl TorrentState = "forceDL"

	// 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          uint   `json:"tier"` // can be both empty "" and int
	Url           string `json:"url"`
	Status        int    `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"`
}

Jump to

Keyboard shortcuts

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