qbit

package module
v0.0.0-...-8f98b32 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 11 Imported by: 2

README

Go Library: qbit

Go Library used to interact with Qbittorrent. This library is not full-featured, and probably only provides read-only methods to view the download list.

At the time of this writing (creation), the library only supports logging in, and collecting transfer info.

If you'd like new features, please open a GitHub issue or pull request.

Example:

package main

import (
	"log"
	"time"

	"golift.io/qbit"
)

func main() {
	config := &qbit.Config{
		URL:     "http://localhost:8080",
		User:    "admin",
		Pass:    "qbitpassword",
	}

	qbit, err := qbit.New(config)
	if err != nil {
		log.Fatalln("[ERROR]", err)
	}

	xfers, err := qbit.GetXfers()
	if err != nil {
		log.Fatalln("[ERROR]", err)
	}

	for _, xfer := range xfers {
		log.Println(xfer.Name, xfer.Progress)
	}
}

Documentation

Overview

Package qbit provides a few methods to interact with a qbittorrent installation. This package is in no way complete, and was written for a specific purpose. If you need more features, please open a PR or GitHub Issue with the request.

Index

Constants

View Source
const (
	DefaultTimeout = 1 * time.Minute
)

Package defaults.

Variables

View Source
var (
	ErrLoginFailed = fmt.Errorf("authentication failed")
)

Custom errors returned by this package.

Functions

This section is empty.

Types

type Config

type Config struct {
	URL      string       `json:"url" toml:"url" xml:"url" yaml:"url"`
	User     string       `json:"user" toml:"user" xml:"user" yaml:"user"`
	Pass     string       `json:"pass" toml:"pass" xml:"pass" yaml:"pass"`
	HTTPPass string       `json:"http_pass" toml:"http_pass" xml:"http_pass" yaml:"http_pass"`
	HTTPUser string       `json:"http_user" toml:"http_user" xml:"http_user" yaml:"http_user"`
	Client   *http.Client `json:"-" toml:"-" xml:"-" yaml:"-"`
}

Config is the input data needed to return a Qbit struct. This is setup to allow you to easily pass this data in from a config file.

type Qbit

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

Qbit is what you get in return for passing in a valid Config to New().

func New

func New(ctx context.Context, config *Config) (*Qbit, error)

func NewNoAuth

func NewNoAuth(config *Config) (*Qbit, error)

func (*Qbit) GetXfers

func (q *Qbit) GetXfers() ([]*Xfer, error)

GetXfers returns data about all transfers/downloads in the Qbit client.

func (*Qbit) GetXfersContext

func (q *Qbit) GetXfersContext(ctx context.Context) ([]*Xfer, error)

GetXfersContext returns data about all transfers/downloads in the Qbit client.

type Xfer

type Xfer struct {
	AddedOn           int     `json:"added_on"`
	AmountLeft        int     `json:"amount_left"`
	AutoTmm           bool    `json:"auto_tmm"`
	Availability      float64 `json:"availability"`
	Category          string  `json:"category"`
	Completed         int     `json:"completed"`
	CompletionOn      int     `json:"completion_on"`
	ContentPath       string  `json:"content_path"`
	DlLimit           int     `json:"dl_limit"`
	Dlspeed           int     `json:"dlspeed"`
	Downloaded        int     `json:"downloaded"`
	DownloadedSession int     `json:"downloaded_session"`
	Eta               int     `json:"eta"`
	FLPiecePrio       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          float64 `json:"max_ratio"`
	MaxSeedingTime    int     `json:"max_seeding_time"`
	Name              string  `json:"name"`
	NumComplete       int     `json:"num_complete"`
	NumIncomplete     int     `json:"num_incomplete"`
	NumLeechs         int     `json:"num_leechs"`
	NumSeeds          int     `json:"num_seeds"`
	Priority          int     `json:"priority"`
	Progress          float64 `json:"progress"`
	Ratio             float64 `json:"ratio"`
	RatioLimit        float64 `json:"ratio_limit"`
	SavePath          string  `json:"save_path"`
	SeedingTime       int64   `json:"seeding_time"`
	SeedingTimeLimit  int64   `json:"seeding_time_limit"`
	SeenComplete      int64   `json:"seen_complete"`
	SeqDl             bool    `json:"seq_dl"`
	Size              int64   `json:"size"`
	State             string  `json:"state"`
	SuperSeeding      bool    `json:"super_seeding"`
	Tags              string  `json:"tags"`
	TimeActive        int64   `json:"time_active"`
	TotalSize         int64   `json:"total_size"`
	Tracker           string  `json:"tracker"`
	TrackersCount     int     `json:"trackers_count"`
	UpLimit           int64   `json:"up_limit"`
	Uploaded          int64   `json:"uploaded"`
	UploadedSession   int64   `json:"uploaded_session"`
	Upspeed           int64   `json:"upspeed"`
}

Xfer is a transfer from the torrents/info endpoint.

Jump to

Keyboard shortcuts

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