sabnzbd

package module
v0.0.0-...-7da3b37 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 16 Imported by: 0

README

go-sabnzbd

Golang API bindings for SABnzbd

For full API documentation, see: http://wiki.sabnzbd.org/api

See cmd/example/example.go for a usage example

Documentation

Index

Constants

View Source
const (
	PriorityDefault PriorityType = -100
	PriorityPaused               = -2
	PriorityLow                  = -1
	PriorityNormal               = 0
	PriorityHigh                 = 1
	PriorityForced               = 2
)
View Source
const (
	Byte  = 1
	KByte = Byte * 1000
	MByte = KByte * 1000
	GByte = MByte * 1000
	TByte = GByte * 1000
	PByte = TByte * 1000
	EByte = PByte * 1000
)
View Source
const (
	KiByte = 1 << ((iota + 1) * 10)
	MiByte = KByte * 1000
	GiByte = MByte * 1000
	TiByte = GByte * 1000
	PiByte = TByte * 1000
	EiByte = PByte * 1000
)

Variables

View Source
var (
	ErrApikeyIncorrect error = errors.New("API Key Incorrect")
	ErrApikeyRequired  error = errors.New("API Key Required")
)
View Source
var ErrInvalidQueueCompleteAction error = errors.New("invalid queue complete action")

Functions

This section is empty.

Types

type AddNzbOption

type AddNzbOption func(*addNzbConfig) error

func AddNzbCategory

func AddNzbCategory(category string) AddNzbOption

func AddNzbName

func AddNzbName(name string) AddNzbOption

func AddNzbPriority

func AddNzbPriority(priority int) AddNzbOption

func AddNzbScript

func AddNzbScript(script string) AddNzbOption

func AddNzbUnpackingOption

func AddNzbUnpackingOption(unpackingOption int) AddNzbOption

func AddNzbUrl

func AddNzbUrl(url string) AddNzbOption

func AddNzbXCategory

func AddNzbXCategory(xcategory string) AddNzbOption

type BytesFromB

type BytesFromB int

func (*BytesFromB) UnmarshalJSON

func (b *BytesFromB) UnmarshalJSON(data []byte) error

type BytesFromGB

type BytesFromGB int

func (*BytesFromGB) UnmarshalJSON

func (b *BytesFromGB) UnmarshalJSON(data []byte) error

type BytesFromKB

type BytesFromKB int

func (*BytesFromKB) UnmarshalJSON

func (b *BytesFromKB) UnmarshalJSON(data []byte) error

type BytesFromMB

type BytesFromMB int

func (*BytesFromMB) UnmarshalJSON

func (b *BytesFromMB) UnmarshalJSON(data []byte) error

type HistoryResponse

type HistoryResponse struct {
	TotalSize              string        `json:"total_size"`
	MonthSize              string        `json:"month_size"`
	WeekSize               string        `json:"week_size"`
	CacheLimit             string        `json:"cache_limit"`
	Paused                 bool          `json:"paused"`
	NewRelURL              string        `json:"string"`
	RestartRequested       bool          `json:"restart_req"`
	Slots                  []HistorySlot `json:"slots"`
	HelpURI                string        `json:"helpuri"`
	Uptime                 string        `json:"uptime"`
	Version                string        `json:"version"`
	DownloadDiskTotalSpace BytesFromGB   `json:"diskspacetotal1"`
	CompleteDiskTotalSpace BytesFromGB   `json:"diskspacetotal2"`
	ColorScheme            string        `json:"color_scheme"`
	Darwin                 bool          `json:"darwin"`
	NT                     bool          `json:"nt"`
	Status                 string        `json:"status"`
	LastWarning            string        `json:"last_warning"`
	HaveWarnings           string        `json:"have_warnings"`
	CacheArt               string        `json:"cache_art"`
	FinishAction           *string       `json:"finishaction"`
	NoOfSlots              int           `json:"noofslots"`
	CacheSize              string        `json:"cache_size"`
	NewRelease             string        `json:"new_release"`
	PauseInt               string        `json:"pause_int"`
	Bytes                  BytesFromMB   `json:"mb"`
	BytesLeft              BytesFromMB   `json:"mbleft"`
	TimeLeft               SabDuration   `json:"timeleft"`
	ETA                    string        `json:"eta"`
	DownloadDiskFreeSpace  BytesFromGB   `json:"diskspace1"`
	CompleteDiskFreeSpace  BytesFromGB   `json:"diskspace2"`
	NZBQuota               string        `json:"nzb_quota"`
	LoadAverage            string        `json:"loadavg"`
	BytesPerSec            BytesFromKB   `json:"kbpersec"`
	SpeedLimit             string        `json:"speedlimit"`
	WebDir                 string        `json:"webdir"`
	// contains filtered or unexported fields
}

func (HistoryResponse) Error

func (e HistoryResponse) Error() string

func (*HistoryResponse) UnmarshalJSON

func (r *HistoryResponse) UnmarshalJSON(data []byte) error

type HistorySlot

type HistorySlot struct {
	ActionLine             string `json:"action_line"`
	ShowDetails            string `json:"show_details"`
	ScriptLog              string `json:"script_log"`
	FailMessage            string `json:"fail_message"`
	Loaded                 bool   `json:"loaded"`
	ID                     int    `json:"id"`
	Size                   string `json:"size"`
	Category               string `json:"category"`
	PP                     string `json:"pp"`
	Completeness           int    `json:"completeness"`
	Script                 string `json:"script"`
	NZBName                string `json:"nzb_name"`
	DownloadTime           int64  `json:"download_time"`
	DownloadDuration       time.Duration
	Storage                string `json:"storage"`
	Status                 string `json:"status"`
	ScriptLine             string `json:"script_line"`
	CompletedUnix          int64  `json:"completed"`
	Completed              time.Time
	NzoID                  string `json:"nzo_id"`
	Downloaded             int64  `json:"downloaded"` // represents downloaded bytes, not time
	Report                 string `json:"report"`
	Path                   string `json:"path"`
	PostProcessingTime     int64  `json:"postproc_time"`
	PostProcessingDuration time.Duration
	Name                   string            `json:"name"`
	URL                    string            `json:"url"`
	Bytes                  int               `json:"bytes"`
	URLInfo                string            `json:"url_info"`
	StageLogs              []HistoryStageLog `json:"stage_log"`
}

type HistoryStageLog

type HistoryStageLog struct {
	Name    string   `json:"name"`
	Actions []string `json:"actions"`
}

type ItemFile

type ItemFile struct {
	ID        string      `json:"id"`
	NzfID     string      `json:"nzf_id"`
	Status    string      `json:"status"`
	Filename  string      `json:"filename"`
	Age       string      `json:"age"`
	Bytes     BytesFromB  `json:"bytes"`
	BytesLeft BytesFromMB `json:"mbleft"`
}

func (*ItemFile) UnmarshalJSON

func (f *ItemFile) UnmarshalJSON(data []byte) (err error)

type ItemFilesResponse

type ItemFilesResponse struct {
	Files []ItemFile `json:"files"`
	// contains filtered or unexported fields
}

func (ItemFilesResponse) Error

func (e ItemFilesResponse) Error() string

type Option

type Option func(*Sabnzbd) error

func Addr

func Addr(addr string) Option

func ApikeyAuth

func ApikeyAuth(apikey string) Option

func LoginAuth

func LoginAuth(username, password string) Option

func NoneAuth

func NoneAuth() Option

func Path

func Path(path string) Option

func SecureAddr

func SecureAddr(host string) Option

func UseHTTPAuth

func UseHTTPAuth(user, pass string) Option

func UseHttp

func UseHttp() Option

func UseHttps

func UseHttps() Option

func UseInsecureHTTP

func UseInsecureHTTP() Option

func UseRoundTripper

func UseRoundTripper(rt http.RoundTripper) Option

type PostProcessingMethod

type PostProcessingMethod uint
const (
	PostProcessingSkip PostProcessingMethod = iota
	PostProcessingRepair
	PostProcessingRepairUnpack
	PostProcessingRepairUnpackDelete
)

type PriorityType

type PriorityType int

type QueueCompleteAction

type QueueCompleteAction uint
const (
	QueueCompleteShutdownPC QueueCompleteAction = iota
	QueueCompleteHibernatePC
	QueueCompleteStandbyPC
	QueueCompleteShutdownProgram
)

type QueueResponse

type QueueResponse struct {
	CacheLimit             string      `json:"cache_limit"`
	Categories             []string    `json:"categories"`
	Scripts                []string    `json:"scripts"`
	Paused                 bool        `json:"paused"`
	NewRelURL              string      `json:"new_rel_url"`
	RestartRequested       bool        `json:"restart_req"`
	Slots                  []QueueSlot `json:"slots"`
	HelpURI                string      `json:"helpuri"`
	Uptime                 string      `json:"uptime"`
	RefreshRate            string      `json:"refresh_rate"`
	IsVerbose              bool        `json:"isverbose"`
	Start                  int         `json:"start"`
	Version                string      `json:"version"`
	DownloadDiskTotalSpace BytesFromGB `json:"diskspacetotal1"`
	CompleteDiskTotalSpace BytesFromGB `json:"diskspacetotal2"`
	ColorScheme            string      `json:"color_scheme"`
	Darwin                 bool        `json:"darwin"`
	NT                     bool        `json:"nt"`
	Status                 string      `json:"status"`
	LastWarning            string      `json:"last_warning"`
	HaveWarnings           string      `json:"have_warnings"`
	CacheArt               string      `json:"cache_art"`
	FinishAction           *string     `json:"finishaction"`
	NoOfSlots              int         `json:"noofslots"`
	CacheSize              string      `json:"cache_size"`
	Finish                 int         `json:"finish"`
	NewRelease             string      `json:"new_release"`
	PauseInt               string      `json:"pause_int"`
	Bytes                  BytesFromMB `json:"mb"`
	BytesLeft              BytesFromMB `json:"mbleft"`
	TimeLeft               SabDuration `json:"timeleft"`
	ETA                    string      `json:"eta"`
	DownloadDiskFreeSpace  BytesFromGB `json:"diskspace1"`
	CompleteDiskFreeSpace  BytesFromGB `json:"diskspace2"`
	NZBQuota               string      `json:"nzb_quota"`
	LoadAverage            string      `json:"loadavg"`
	Limit                  int         `json:"limit"`
	BytesPerSec            BytesFromKB `json:"kbpersec"`
	SpeedLimit             string      `json:"speedlimit"`
	WebDir                 string      `json:"webdir"`
	QueueDetails           string      `json:"queue_details"`
	// contains filtered or unexported fields
}

func (QueueResponse) Error

func (e QueueResponse) Error() string

func (*QueueResponse) UnmarshalJSON

func (r *QueueResponse) UnmarshalJSON(data []byte) error

type QueueSlot

type QueueSlot struct {
	Status     string      `json:"status"`
	Index      int         `json:"index"`
	ETA        string      `json:"eta"`
	TimeLeft   SabDuration `json:"timeleft"`
	AverageAge string      `json:"avg_age"`
	Script     string      `json:"script"`
	MsgID      string      `json:"msgid"`
	Verbosity  string      `json:"verbosity"`
	Bytes      BytesFromMB `json:"mb"`
	Filename   string      `json:"filename"`
	Priority   string      `json:"priority"`
	Category   string      `json:"cat"`
	BytesLeft  BytesFromMB `json:"mbleft"`
	Percentage string      `json:"percentage"`
	NzoID      string      `json:"nzo_id"`
	UnpackOpts string      `json:"unpackopts"`
	Size       string      `json:"size"`
}

type SabDuration

type SabDuration time.Duration

func (*SabDuration) UnmarshalJSON

func (d *SabDuration) UnmarshalJSON(data []byte) error

type Sabnzbd

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

func New

func New(options ...Option) (s *Sabnzbd, err error)

func SecureClient

func SecureClient(host, apikey string) (*Sabnzbd, error)

func SimpleClient

func SimpleClient(addr, apikey string) (*Sabnzbd, error)

func (*Sabnzbd) AddFile

func (s *Sabnzbd) AddFile(filename string, options ...AddNzbOption) (nzoids []string, err error)

func (*Sabnzbd) AddLocalfile

func (s *Sabnzbd) AddLocalfile(filename string, options ...AddNzbOption) (nzoids []string, err error)

func (*Sabnzbd) AddReader

func (s *Sabnzbd) AddReader(reader io.Reader, filename string, options ...AddNzbOption) (nzoids []string, err error)

func (*Sabnzbd) AddURL

func (s *Sabnzbd) AddURL(options ...AddNzbOption) (nzoids []string, err error)

func (*Sabnzbd) AdvancedQueue

func (s *Sabnzbd) AdvancedQueue(start, limit int) (r *QueueResponse, err error)

func (*Sabnzbd) Auth

func (s *Sabnzbd) Auth() (auth string, err error)

func (*Sabnzbd) Categories

func (s *Sabnzbd) Categories() (categories []string, err error)

func (*Sabnzbd) ChangeCategory

func (s *Sabnzbd) ChangeCategory(nzoid, category string) (err error)

func (*Sabnzbd) ChangeName

func (s *Sabnzbd) ChangeName(nzoid, name string) (err error)

func (*Sabnzbd) ChangePostProcessing

func (s *Sabnzbd) ChangePostProcessing(nzoid string, method PostProcessingMethod) (err error)

func (*Sabnzbd) ChangePriority

func (s *Sabnzbd) ChangePriority(nzoid string, priority PriorityType) (err error)

func (*Sabnzbd) ChangeQueueCompleteAction

func (s *Sabnzbd) ChangeQueueCompleteAction(action QueueCompleteAction) (err error)

func (*Sabnzbd) ChangeScript

func (s *Sabnzbd) ChangeScript(nzoid, script string) (err error)

func (*Sabnzbd) Delete

func (s *Sabnzbd) Delete(removeFiles bool, nzos ...string) (err error)

func (*Sabnzbd) DeleteAll

func (s *Sabnzbd) DeleteAll(removeFiles bool) (err error)

func (*Sabnzbd) DeleteAllHistory

func (s *Sabnzbd) DeleteAllHistory(removeFailedFiles bool) (err error)

func (*Sabnzbd) DeleteFailedHistory

func (s *Sabnzbd) DeleteFailedHistory(removeFailedFiles bool) (err error)

func (*Sabnzbd) DeleteHistory

func (s *Sabnzbd) DeleteHistory(removeFailedFiles bool, nzos ...string) (err error)

func (*Sabnzbd) GetItemFiles

func (s *Sabnzbd) GetItemFiles(nzoid string) (files []ItemFile, err error)

func (*Sabnzbd) History

func (s *Sabnzbd) History(start, limit int) (r *HistoryResponse, err error)

func (*Sabnzbd) Move

func (s *Sabnzbd) Move(nzo1, nzo2 string) (err error)

todo deal with return value { "result": { "priority": int, "position": int } }

func (*Sabnzbd) MoveByPriority

func (s *Sabnzbd) MoveByPriority(nzo string, priority int) (err error)

func (*Sabnzbd) Pause

func (s *Sabnzbd) Pause() (err error)

func (*Sabnzbd) PauseItem

func (s *Sabnzbd) PauseItem(nzoid string) (err error)

func (*Sabnzbd) PausePostProcessing

func (s *Sabnzbd) PausePostProcessing() (err error)

func (*Sabnzbd) PauseTemporarily

func (s *Sabnzbd) PauseTemporarily(t time.Duration) (err error)

PauseTemporarily will pause for a time duration. The lowest possible value is one minute. Durations below one minute will resume the queue.

func (*Sabnzbd) Restart

func (s *Sabnzbd) Restart() (err error)

func (*Sabnzbd) Resume

func (s *Sabnzbd) Resume() (err error)

func (*Sabnzbd) ResumeItem

func (s *Sabnzbd) ResumeItem(nzoid string) (err error)

func (*Sabnzbd) ResumePostProcessing

func (s *Sabnzbd) ResumePostProcessing() (err error)

func (*Sabnzbd) Retry

func (s *Sabnzbd) Retry(nzoid string) (err error)

func (*Sabnzbd) Scripts

func (s *Sabnzbd) Scripts() (scripts []string, err error)

func (*Sabnzbd) SetOptions

func (s *Sabnzbd) SetOptions(options ...Option) (err error)

func (*Sabnzbd) Shutdown

func (s *Sabnzbd) Shutdown() (err error)

func (*Sabnzbd) SimpleHistory

func (s *Sabnzbd) SimpleHistory() (r *HistoryResponse, err error)

func (*Sabnzbd) SimpleQueue

func (s *Sabnzbd) SimpleQueue() (r *QueueResponse, err error)

func (*Sabnzbd) SpeedLimit

func (s *Sabnzbd) SpeedLimit(kbps int) (err error)

func (*Sabnzbd) Version

func (s *Sabnzbd) Version() (version string, err error)

func (*Sabnzbd) Warnings

func (s *Sabnzbd) Warnings() (warnings []string, err error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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