nzbget

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 9 Imported by: 3

README

NZBGet Go Module

GoDoc Go Report Card MIT License discord

Full-featured Go Library to interact with NZBGet's JSON RPC interface. See exposed methods below.

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

Examples

Simple example to print some logs.

package main

import (
	"fmt"

	"golift.io/nzbget"
)

func main() {
	nzb := nzbget.New(&nzbget.Config{
		URL:  "http://nzbget.server.io:6789/",
		User: "userName",
		Pass: "passWord",
	})

	events, err := nzb.Log(0, 100)
	if err != nil {
		panic(err)
	}

	nzbVer, err := nzb.Version()
	if err != nil {
		panic(err)
	}

	fmt.Println("NZBGet Version: ", nzbVer)

	for _, event := range events {
		fmt.Println(event.ID, event.Kind, event.Time, event.Text)
	}
}
// Output:
// NZBGet Version:  21.1
// 47 INFO 2022-06-27 01:42:19 -0700 PDT Renaming 0b710bf619488ca0a1b5f83f53fde577.15 to eQ7Aq0DBEhHGCgSXy3PZ.part16.rar
// 103 INFO 2022-06-27 01:42:23 -0700 PDT Unrar: Extracting from eQ7Aq0DBEhHGCgSXy3PZ.part28.rar
// 104 INFO 2022-06-27 01:42:24 -0700 PDT Unrar: All OK
// 105 INFO 2022-06-27 01:42:24 -0700 PDT Deleting archive files
// 106 INFO 2022-06-27 01:42:24 -0700 PDT Deleting file eQ7Aq0DBEhHGCgSXy3PZ.part21.rar

Methods

Official NZBGet API reference can be found here.

All of these methods are exposed.

Program Control
Queue and History
Status, Logging and Statistics
Pause and Speed Limit
Configuration

Documentation

Index

Constants

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

Package defaults.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendInput added in v0.1.1

type AppendInput struct {
	Filename   string
	Content    string
	Category   string
	Priority   int64
	AddToTop   bool
	AddPaused  bool
	DupeKey    string // See: https://nzbget.net/rss#duplicate-keys
	DupeScore  int64  // See: https://nzbget.net/rss#duplicate-scores
	DupeMode   string // See: https://nzbget.net/rss#duplicate-modes
	Parameters []*Parameter
}

AppendInput is the input data for the append method. See https://nzbget.net/api/append for more information about this data.

type BytesPer added in v0.1.1

type BytesPer struct {
	SizeLo int64 `json:"SizeLo"` // Amount of downloaded data, low 32-bits of 64-bit value.
	SizeHi int64 `json:"SizeHi"` // Amount of downloaded data, high 32-bits of 64-bit value.
	SizeMB int64 `json:"SizeMB"` // Amount of downloaded data, in megabytes.
}

BytesPer is part of the ServerVolume structure.

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"`
	Client *http.Client `json:"-" toml:"-" xml:"-" yaml:"-"` // optional.
}

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

type ConfigTemplate added in v0.1.1

type ConfigTemplate struct {
	Name            string `json:"Name"`            // Post-processing script name. For example “videosort/VideoSort.py”. This field is empty in the first record, which holds the config template of the program itself.
	DisplayName     string `json:"DisplayName"`     // Nice script name ready for displaying. For example “VideoSort”.
	PostScript      bool   `json:"PostScript"`      // “True” for post-processing scripts.
	ScanScript      bool   `json:"ScanScript"`      // “True” for scan scripts.
	QueueScript     bool   `json:"QueueScript"`     // “True” for queue scripts.
	SchedulerScript bool   `json:"SchedulerScript"` // “True” for scheduler scripts.
	Template        string `json:"Template"`        // Content of the configuration template (multiple lines).
}

ConfigTemplate represents the configtemplate RPC endpoint output.

type DeleteStatus

type DeleteStatus string

DeleteStatus determine if and why a download was removed.

const (
	DeleteNONE   DeleteStatus = "NONE"   // not deleted;
	DeleteMANUAL DeleteStatus = "MANUAL" // the download was manually deleted by user;
	DeleteHEALTH DeleteStatus = "HEALTH" // the download was deleted by health check;
	DeleteDUPE   DeleteStatus = "DUPE"   // the download was deleted by duplicate check;
	DeleteBAD    DeleteStatus = "BAD"    // v14.0 the download was marked as BAD by a queue//script during download;
	DeleteSCAN   DeleteStatus = "SCAN"   // v16.0 the download was deleted because the nzb//file could not be parsed (malformed nzb//file);
	DeleteCOPY   DeleteStatus = "COPY"   // v16.0 the download was deleted by duplicate check because an nzb//file with exactly same content exists
)

DeleteStatuses go here.

type ExParStatus

type ExParStatus string

ExParStatus determines if the download was repaired using duplicate par-scan mode.

const (
	ExParRECIPIENT ExParStatus = "RECIPIENT" // repaired using blocks from other duplicates;
	ExParDONOR     ExParStatus = "DONOR"     // has donated blocks to repair another duplicate;
)

ExParStatuses go here.

type File

type File struct {
	ID                int64  `json:"ID"`                // ID of file.
	NZBID             int64  `json:"NZBID"`             // ID of NZB//file.
	NZBFilename       string `json:"NZBFilename"`       // Name of nzb//file. The filename could include fullpath if client sent it by adding the file to queue.
	NZBName           string `json:"NZBName"`           // The name of nzb//file without path and extension. Ready for user//friendly output.
	Subject           string `json:"Subject"`           // Subject of article read from nzb//file.
	Filename          string `json:"Filename"`          // Filename parsed from subject. It could be incorrect since the subject not always correct formated. After the first article for file is read, the correct filename is read from article body.
	FilenameConfirmed bool   `json:"FilenameConfirmed"` // “True” if filename was already read from article’s body. “False” if the name was parsed from subject. For confirmed filenames the destination file on disk will be exactly as specified in field “filename”. For unconfirmed filenames the name could change later.
	DestDir           string `json:"DestDir"`           // Destination directory for output file.
	FileSizeLo        int64  `json:"FileSizeLo"`        // Filesize in bytes, Low 32//bits of 64//bit value.
	FileSizeHi        int64  `json:"FileSizeHi"`        // Filesize in bytes, High 32//bits of 64//bit value.
	RemainingSizeLo   int64  `json:"RemainingSizeLo"`   // Remaining size in bytes, Low 32//bits of 64//bit value.
	RemainingSizeHi   int64  `json:"RemainingSizeHi"`   // Remaining size in bytes, High 32//bits of 64//bit value.
	Paused            bool   `json:"Paused"`            // “True” if file is paused.
	PostTime          int64  `json:"PostTime"`          // Date/time when the file was posted to newsgroup Time is in C/Unix format.
	ActiveDownloads   int64  `json:"ActiveDownloads"`   // Number of active downloads for the file. With this filed can be determined what files is are being currently downloaded.
	Progress          int64  `json:"Progress"`          // v15.0 Download progress, a number in the range 0..1000. Divide it to 10 to get percent//value.
}

File represents the listFiles RPC endpoint.

type Group

type Group struct {
	NZBID              int64             `json:"NZBID"`
	RemainingSizeLo    int64             `json:"RemainingSizeLo"`
	RemainingSizeHi    int64             `json:"RemainingSizeHi"`
	RemainingSizeMB    int64             `json:"RemainingSizeMB"`
	PausedSizeLo       int64             `json:"PausedSizeLo"`
	PausedSizeHi       int64             `json:"PausedSizeHi"`
	PausedSizeMB       int64             `json:"PausedSizeMB"`
	RemainingFileCount int64             `json:"RemainingFileCount"`
	RemainingParCount  int64             `json:"RemainingParCount"`
	MaxPriority        int64             `json:"MaxPriority"`
	ActiveDownloads    int64             `json:"ActiveDownloads"`
	Status             GroupStatus       `json:"Status"`
	NZBName            string            `json:"NZBName"`
	Kind               string            `json:"Kind"`
	URL                string            `json:"URL"`
	NZBFilename        string            `json:"NZBFilename"`
	DestDir            string            `json:"DestDir"`
	FinalDir           string            `json:"FinalDir"`
	Category           string            `json:"Category"`
	ParStatus          ParStatus         `json:"ParStatus"`
	ExParStatus        ExParStatus       `json:"ExParStatus"`
	UnpackStatus       UnpackStatus      `json:"UnpackStatus"`
	MoveStatus         MoveStatus        `json:"MoveStatus"`
	ScriptStatus       ScriptStatus      `json:"ScriptStatus"`
	DeleteStatus       DeleteStatus      `json:"DeleteStatus"`
	MarkStatus         MarkStatus        `json:"MarkStatus"`
	URLStatus          URLStatus         `json:"UrlStatus"`
	FileSizeLo         int64             `json:"FileSizeLo"`
	FileSizeHi         int64             `json:"FileSizeHi"`
	FileSizeMB         int64             `json:"FileSizeMB"`
	FileCount          int64             `json:"FileCount"`
	MinPostTime        Time              `json:"MinPostTime"`
	MaxPostTime        Time              `json:"MaxPostTime"`
	TotalArticles      int64             `json:"TotalArticles"`
	SuccessArticles    int64             `json:"SuccessArticles"`
	FailedArticles     int64             `json:"FailedArticles"`
	Health             int64             `json:"Health"`
	CriticalHealth     int64             `json:"CriticalHealth"`
	DupeScore          int64             `json:"DupeScore"`
	DupeKey            string            `json:"DupeKey"`
	DupeMode           string            `json:"DupeMode"`
	DownloadedSizeLo   int64             `json:"DownloadedSizeLo"`
	DownloadedSizeHi   int64             `json:"DownloadedSizeHi"`
	DownloadedSizeMB   int64             `json:"DownloadedSizeMB"`
	DownloadTimeSec    int64             `json:"DownloadTimeSec"`
	PostTotalTimeSec   int64             `json:"PostTotalTimeSec"`
	ParTimeSec         int64             `json:"ParTimeSec"`
	RepairTimeSec      int64             `json:"RepairTimeSec"`
	UnpackTimeSec      int64             `json:"UnpackTimeSec"`
	MessageCount       int64             `json:"MessageCount"`
	ExtraParBlocks     int64             `json:"ExtraParBlocks"`
	Parameters         []Parameter       `json:"Parameters"`
	ScriptStatuses     []PerScriptStatus `json:"ScriptStatuses"`
	ServerStats        []ServerStats     `json:"ServerStats"`
	PostInfoText       string            `json:"PostInfoText"`
	PostStageProgress  int64             `json:"PostStageProgress"`
	PostStageTimeSec   int64             `json:"PostStageTimeSec"`
}

Group represents the listGroups RPC endpoint.

type GroupStatus

type GroupStatus string

GroupStatus determines the current status of a download group.

const (
	GroupQUEUED            GroupStatus = "QUEUED"             // queued for download;
	GroupPAUSED            GroupStatus = "PAUSED"             // paused;
	GroupDOWNLOADING       GroupStatus = "DOWNLOADING"        // item is being downloaded;
	GroupFETCHING          GroupStatus = "FETCHING"           // nzbGroupStatus = "" //file is being fetched from URL (Kind=URL);
	GroupPPQUEUED          GroupStatus = "PP_QUEUED"          // queued for postGroupStatus = "" //processing (completely downloaded);
	GroupLOADINGPARS       GroupStatus = "LOADING_PARS"       // stage of parGroupStatus = "" //check;
	GroupVERIFYINGSOURCES  GroupStatus = "VERIFYING_SOURCES"  // stage of parGroupStatus = "" //check;
	GroupREPAIRING         GroupStatus = "REPAIRING"          // stage of parGroupStatus = "" //check;
	GroupVERIFYINGREPAIRED GroupStatus = "VERIFYING_REPAIRED" // stage of parGroupStatus = "" //check;
	GroupRENAMING          GroupStatus = "RENAMING"           // processed by parGroupStatus = "" //renamer;
	GroupUNPACKING         GroupStatus = "UNPACKING"          // being unpacked;
	GroupMOVING            GroupStatus = "MOVING"             // moving files from intermediate directory into destination directory;
	GroupEXECUTINGSCRIPT   GroupStatus = "EXECUTING_SCRIPT"   // executing postGroupStatus = "" //processing script;
	GroupPPFINISHED        GroupStatus = "PP_FINISHED"        // postGroupStatus = "" //processing is finished, the item is about to be moved to history.
)

GroupStatuses go here.

type History

type History struct {
	NZBID              int64             `json:"NZBID"`
	Name               string            `json:"Name"`
	RemainingFileCount int64             `json:"RemainingFileCount"`
	HistoryTime        Time              `json:"HistoryTime"`
	Status             string            `json:"Status"`
	NZBName            string            `json:"NZBName"`
	Kind               string            `json:"Kind"`
	URL                string            `json:"URL"`
	NZBFilename        string            `json:"NZBFilename"`
	DestDir            string            `json:"DestDir"`
	FinalDir           string            `json:"FinalDir"`
	Category           string            `json:"Category"`
	ParStatus          ParStatus         `json:"ParStatus"`
	ExParStatus        ExParStatus       `json:"ExParStatus"`
	UnpackStatus       UnpackStatus      `json:"UnpackStatus"`
	MoveStatus         MoveStatus        `json:"MoveStatus"`
	ScriptStatus       ScriptStatus      `json:"ScriptStatus"`
	DeleteStatus       DeleteStatus      `json:"DeleteStatus"`
	MarkStatus         MarkStatus        `json:"MarkStatus"`
	URLStatus          URLStatus         `json:"UrlStatus"`
	FileSizeLo         int64             `json:"FileSizeLo"`
	FileSizeHi         int64             `json:"FileSizeHi"`
	FileSizeMB         int64             `json:"FileSizeMB"`
	FileCount          int64             `json:"FileCount"`
	MinPostTime        Time              `json:"MinPostTime"`
	MaxPostTime        Time              `json:"MaxPostTime"`
	TotalArticles      int64             `json:"TotalArticles"`
	SuccessArticles    int64             `json:"SuccessArticles"`
	FailedArticles     int64             `json:"FailedArticles"`
	Health             int64             `json:"Health"`
	CriticalHealth     int64             `json:"CriticalHealth"`
	DupeScore          int64             `json:"DupeScore"`
	DupeKey            string            `json:"DupeKey"`
	DupeMode           string            `json:"DupeMode"`
	DownloadedSizeLo   int64             `json:"DownloadedSizeLo"`
	DownloadedSizeHi   int64             `json:"DownloadedSizeHi"`
	DownloadedSizeMB   int64             `json:"DownloadedSizeMB"`
	DownloadTimeSec    int64             `json:"DownloadTimeSec"`
	PostTotalTimeSec   int64             `json:"PostTotalTimeSec"`
	ParTimeSec         int64             `json:"ParTimeSec"`
	RepairTimeSec      int64             `json:"RepairTimeSec"`
	UnpackTimeSec      int64             `json:"UnpackTimeSec"`
	MessageCount       int64             `json:"MessageCount"`
	ExtraParBlocks     int64             `json:"ExtraParBlocks"`
	RetryData          bool              `json:"RetryData"`
	Parameters         []Parameter       `json:"Parameters"`
	ScriptStatuses     []PerScriptStatus `json:"ScriptStatuses"`
	ServerStats        []ServerStats     `json:"ServerStats"`
}

History represents the hisory RPC endpoint.

type LogEntry

type LogEntry struct {
	ID   int64   `json:"ID"`
	Time Time    `json:"Time"`
	Kind LogKind `json:"Kind"`
	Text string  `json:"Text"`
}

LogEntry represents the log RPC endpoint.

type LogKind

type LogKind string

LogKind determines the kind of log entry.

const (
	LogINFO    LogKind = "INFO"
	LogWARNING LogKind = "WARNING"
	LogERROR   LogKind = "ERROR"
	LogDETAIL  LogKind = "DETAIL"
	LogDEBUG   LogKind = "DEBUG" // only if compiled in debug mode.
)

LogKinds go here.

type MarkStatus

type MarkStatus string

MoveStatus determines if the download was marked by a user.

const (
	MarkNONE MarkStatus = "NONE" // not marked;
	MarkGOOD MarkStatus = "GOOD" // the download was marked as good by user using command Mark as good in history dialog;
	MarkBAD  MarkStatus = "BAD"  // the download was marked as bad by user using command Mark as bad in history dialog;
)

MarkStatuses go here.

type MoveStatus

type MoveStatus string

MoveStatus determines the result of moving files from intermediate directory into final directory.

const (
	MoveNONE    MoveStatus = "NONE"    // the moving wasn’t made because either the option InterDir is not in use or the par-check or unpack have failed;
	MoveSUCCESS MoveStatus = "SUCCESS" // files were moved successfully;
	MoveFAILURE MoveStatus = "FAILURE" // the moving has failed.
)

MoveStatuses go here.

type NZBGet

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

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

func New

func New(config *Config) *NZBGet

func (*NZBGet) Append added in v0.1.1

func (n *NZBGet) Append(input *AppendInput) (int64, error)

Append adds a nzb-file or URL to the download queue. https://nzbget.net/api/append

func (*NZBGet) AppendContext added in v0.1.3

func (n *NZBGet) AppendContext(ctx context.Context, input *AppendInput) (int64, error)

AppendContext adds a nzb-file or URL to the download queue. https://nzbget.net/api/append

func (*NZBGet) Config

func (n *NZBGet) Config() ([]*Parameter, error)

Config returns the loaded and active NZBGet configuration parameters. https://nzbget.net/api/config

func (*NZBGet) ConfigContext added in v0.1.3

func (n *NZBGet) ConfigContext(ctx context.Context) ([]*Parameter, error)

ConfigContext returns the loaded and active NZBGet configuration parameters. https://nzbget.net/api/config

func (*NZBGet) ConfigTemplates added in v0.1.1

func (n *NZBGet) ConfigTemplates(loadFromDisk bool) ([]*ConfigTemplate, error)

ConfigTemplates returns NZBGet configuration file template and also extracts configuration sections from all post-processing files. This information is for example used by web-interface to build settings page or page “Postprocess” in download details dialog. https://nzbget.net/api/configtemplates

func (*NZBGet) ConfigTemplatesContext added in v0.1.3

func (n *NZBGet) ConfigTemplatesContext(ctx context.Context, loadFromDisk bool) ([]*ConfigTemplate, error)

ConfigTemplatesContext returns NZBGet configuration file template and also extracts configuration sections from all post-processing files. This information is for example used by web-interface to build settings page or page “Postprocess” in download details dialog. https://nzbget.net/api/configtemplates

func (*NZBGet) EditQueue added in v0.1.1

func (n *NZBGet) EditQueue(command, parameter string, ids []int64) (bool, error)

EditQueue edits items in download queue or in history. Read the official docs for how to issue commands, and which commands are available. https://nzbget.net/api/editqueue

func (*NZBGet) EditQueueContext added in v0.1.3

func (n *NZBGet) EditQueueContext(ctx context.Context, command, parameter string, ids []int64) (bool, error)

EditQueueContext edits items in download queue or in history. Read the official docs for how to issue commands, and which commands are available. https://nzbget.net/api/editqueue

func (*NZBGet) GetInto

func (n *NZBGet) GetInto(ctx context.Context, method string, output interface{}, args ...interface{}) error

GetInto is a helper method to make a JSON-RPC request and turn the response into structured data.

func (*NZBGet) History

func (n *NZBGet) History(hidden bool) ([]*History, error)

History returns the NZBGet Download History. https://nzbget.net/api/history

func (*NZBGet) HistoryContext added in v0.1.3

func (n *NZBGet) HistoryContext(ctx context.Context, hidden bool) ([]*History, error)

HistoryContext returns the NZBGet Download History. https://nzbget.net/api/history

func (*NZBGet) ListFiles

func (n *NZBGet) ListFiles(nzbID int64) (*File, error)

ListFiles returns the NZBGet Files for a download. https://nzbget.net/api/listfiles nzbID is the NZBID of the group to be returned. Use 0 for all file groups.

func (*NZBGet) ListFilesContext added in v0.1.3

func (n *NZBGet) ListFilesContext(ctx context.Context, nzbID int64) (*File, error)

ListFilesContext returns the NZBGet Files for a download. https://nzbget.net/api/listfiles nzbID is the NZBID of the group to be returned. Use 0 for all file groups.

func (*NZBGet) ListGroups

func (n *NZBGet) ListGroups() ([]*Group, error)

ListGroups returns the NZBGet Download list. https://nzbget.net/api/listgroups

func (*NZBGet) ListGroupsContext added in v0.1.3

func (n *NZBGet) ListGroupsContext(ctx context.Context) ([]*Group, error)

ListGroupsContext returns the NZBGet Download list. https://nzbget.net/api/listgroups

func (*NZBGet) LoadConfig

func (n *NZBGet) LoadConfig() ([]*Parameter, error)

LoadConfig returns the configuration from disk. https://nzbget.net/api/loadconfig

func (*NZBGet) LoadConfigContext added in v0.1.3

func (n *NZBGet) LoadConfigContext(ctx context.Context) ([]*Parameter, error)

LoadConfigContext returns the configuration from disk. https://nzbget.net/api/loadconfig

func (*NZBGet) LoadLog

func (n *NZBGet) LoadLog(nzbID, startID, limit int64) ([]*LogEntry, error)

LoadLog returns the NZBGet log for a specific download. NOTE: only one of either startID or limit - can be specified. The other parameter must be 0. https://nzbget.net/api/loadlog

func (*NZBGet) LoadLogContext added in v0.1.3

func (n *NZBGet) LoadLogContext(ctx context.Context, nzbID, startID, limit int64) ([]*LogEntry, error)

LoadLogContext returns the NZBGet log for a specific download. NOTE: only one of either startID or limit - can be specified. The other parameter must be 0. https://nzbget.net/api/loadlog

func (*NZBGet) Log

func (n *NZBGet) Log(startID, limit int64) ([]*LogEntry, error)

Log returns the NZBGet Logs. NOTE: only one parameter - either startID or limit - can be specified. The other parameter must be 0. https://nzbget.net/api/log

func (*NZBGet) LogContext added in v0.1.3

func (n *NZBGet) LogContext(ctx context.Context, startID, limit int64) ([]*LogEntry, error)

LogContext returns the NZBGet Logs. NOTE: only one parameter - either startID or limit - can be specified. The other parameter must be 0. https://nzbget.net/api/log

func (*NZBGet) PauseDownload

func (n *NZBGet) PauseDownload() (bool, error)

PauseDownload pauses downloads. https://nzbget.net/api/pausedownload

func (*NZBGet) PauseDownloadContext added in v0.1.3

func (n *NZBGet) PauseDownloadContext(ctx context.Context) (bool, error)

PauseDownloadContext pauses downloads. https://nzbget.net/api/pausedownload

func (*NZBGet) PausePost

func (n *NZBGet) PausePost() (bool, error)

PausePost pauses post processing. https://nzbget.net/api/pausepost

func (*NZBGet) PausePostContext added in v0.1.3

func (n *NZBGet) PausePostContext(ctx context.Context) (bool, error)

PausePostContext pauses post processing. https://nzbget.net/api/pausepost

func (*NZBGet) PauseScan

func (n *NZBGet) PauseScan() (bool, error)

PauseScan pauses scanning of directory with incoming nzb-files. https://nzbget.net/api/pausescan

func (*NZBGet) PauseScanContext added in v0.1.3

func (n *NZBGet) PauseScanContext(ctx context.Context) (bool, error)

PauseScanContext pauses scanning of directory with incoming nzb-files. https://nzbget.net/api/pausescan

func (*NZBGet) Rate

func (n *NZBGet) Rate(limit int64) (bool, error)

Rate sets download speed limit. https://nzbget.net/api/rate

func (*NZBGet) RateContext added in v0.1.3

func (n *NZBGet) RateContext(ctx context.Context, limit int64) (bool, error)

RateContext sets download speed limit. https://nzbget.net/api/rate

func (*NZBGet) Reload

func (n *NZBGet) Reload() (bool, error)

Reload makes NZBGet stop all activities and reinitialize. https://nzbget.net/api/reload

func (*NZBGet) ReloadContext added in v0.1.3

func (n *NZBGet) ReloadContext(ctx context.Context) (bool, error)

ReloadContext makes NZBGet stop all activities and reinitialize. https://nzbget.net/api/reload

func (*NZBGet) ResetServerVolume added in v0.1.1

func (n *NZBGet) ResetServerVolume(serverID int64, sounter string) (bool, error)

ResetServerVolume resets download volume statistics for a specified news-server. https://nzbget.net/api/resetservervolume

func (*NZBGet) ResetServerVolumeContext added in v0.1.3

func (n *NZBGet) ResetServerVolumeContext(ctx context.Context, serverID int64, sounter string) (bool, error)

ResetServerVolumeContext resets download volume statistics for a specified news-server. https://nzbget.net/api/resetservervolume

func (*NZBGet) ResumeDownload

func (n *NZBGet) ResumeDownload() (bool, error)

ResumeDownload resumes downloads. https://nzbget.net/api/resumedownload

func (*NZBGet) ResumeDownloadContext added in v0.1.3

func (n *NZBGet) ResumeDownloadContext(ctx context.Context) (bool, error)

ResumeDownloadContext resumes downloads. https://nzbget.net/api/resumedownload

func (*NZBGet) ResumePost

func (n *NZBGet) ResumePost() (bool, error)

ResumePost resumes post processing. https://nzbget.net/api/resumepost

func (*NZBGet) ResumePostContext added in v0.1.3

func (n *NZBGet) ResumePostContext(ctx context.Context) (bool, error)

ResumePostContext resumes post processing. https://nzbget.net/api/resumepost

func (*NZBGet) ResumeScan

func (n *NZBGet) ResumeScan() (bool, error)

ResumeScan resumes scanning of directory with incoming nzb-files. https://nzbget.net/api/resumescan

func (*NZBGet) ResumeScanContext added in v0.1.3

func (n *NZBGet) ResumeScanContext(ctx context.Context) (bool, error)

ResumeScanContext resumes scanning of directory with incoming nzb-files. https://nzbget.net/api/resumescan

func (*NZBGet) SaveConfig

func (n *NZBGet) SaveConfig(configs []*Parameter) (bool, error)

SaveConfig writes new configuration parameters to disk. https://nzbget.net/api/saveconfig

func (*NZBGet) SaveConfigContext added in v0.1.3

func (n *NZBGet) SaveConfigContext(ctx context.Context, configs []*Parameter) (bool, error)

SaveConfigContext writes new configuration parameters to disk. https://nzbget.net/api/saveconfig

func (*NZBGet) Scan

func (n *NZBGet) Scan() (bool, error)

Scan requests rescanning of incoming directory for nzb-files. https://nzbget.net/api/scheduleresume

func (*NZBGet) ScanContext added in v0.1.3

func (n *NZBGet) ScanContext(ctx context.Context) (bool, error)

ScanContext requests rescanning of incoming directory for nzb-files. https://nzbget.net/api/scheduleresume

func (*NZBGet) ScheduleResume

func (n *NZBGet) ScheduleResume(wait time.Duration) (bool, error)

ScheduleResume schedules resuming of all activities after wait duration elapses. Wait duration is rounded to nearest second. https://nzbget.net/api/scheduleresume

func (*NZBGet) ScheduleResumeContext added in v0.1.3

func (n *NZBGet) ScheduleResumeContext(ctx context.Context, wait time.Duration) (bool, error)

ScheduleResumeContext schedules resuming of all activities after wait duration elapses. Wait duration is rounded to nearest second. https://nzbget.net/api/scheduleresume

func (*NZBGet) ServerVolumes added in v0.1.1

func (n *NZBGet) ServerVolumes() ([]*ServerVolume, error)

ServerVolumes returns download volume statistics per news-server. https://nzbget.net/api/servervolumes NOTE: The first record (serverid=0) are totals for all servers.

func (*NZBGet) ServerVolumesContext added in v0.1.3

func (n *NZBGet) ServerVolumesContext(ctx context.Context) ([]*ServerVolume, error)

ServerVolumesContext returns download volume statistics per news-server. https://nzbget.net/api/servervolumes NOTE: The first record (serverid=0) are totals for all servers.

func (*NZBGet) Shutdown

func (n *NZBGet) Shutdown() (bool, error)

Shutdown makes NZBGet exit. https://nzbget.net/api/shutdown

func (*NZBGet) ShutdownContext added in v0.1.3

func (n *NZBGet) ShutdownContext(ctx context.Context) (bool, error)

ShutdownContext makes NZBGet exit. https://nzbget.net/api/shutdown

func (*NZBGet) Status

func (n *NZBGet) Status() (*Status, error)

Status returns the NZBGet Status. https://nzbget.net/api/status

func (*NZBGet) StatusContext added in v0.1.3

func (n *NZBGet) StatusContext(ctx context.Context) (*Status, error)

StatusContext returns the NZBGet Status. https://nzbget.net/api/status

func (*NZBGet) Version

func (n *NZBGet) Version() (string, error)

Version returns the NZBGet Version. https://nzbget.net/api/version

func (*NZBGet) VersionContext added in v0.1.3

func (n *NZBGet) VersionContext(ctx context.Context) (string, error)

VersionContext returns the NZBGet Version. https://nzbget.net/api/version

func (*NZBGet) WriteLog

func (n *NZBGet) WriteLog(kind LogKind, text string) (bool, error)

WriteLog appends a log entry to th server's log and on-screen log buffer. https://nzbget.net/api/writelog

func (*NZBGet) WriteLogContext added in v0.1.3

func (n *NZBGet) WriteLogContext(ctx context.Context, kind LogKind, text string) (bool, error)

WriteLogContext appends a log entry to th server's log and on-screen log buffer. https://nzbget.net/api/writelog

type NewsServers

type NewsServers struct {
	ID     int64 `json:"ID"`
	Active bool  `json:"Active"`
}

NewsServers is part of the Status endpoint output.

type ParStatus

type ParStatus string

ParStatus determines the result of par-check/repair.

const (
	ParNONE           ParStatus = "NONE"            // par-check wasn’t performed;
	ParFAILURE        ParStatus = "FAILURE"         // par-check has failed;
	ParREPAIRPOSSIBLE ParStatus = "REPAIR_POSSIBLE" // download is damaged, additional par-files were downloaded but the download was not repaired. Either the option ParRepair is disabled or the par-repair was cancelled by option ParTimeLimit;
	ParSUCCESS        ParStatus = "SUCCESS"         // par-check was successful;
	ParMANUAL         ParStatus = "MANUAL"          // download is damaged but was not checked/repaired because option ParCheck is set to Manual.
)

ParStatuses go here.

type Parameter

type Parameter struct {
	Name  string `json:"Name"`
	Value string `json:"Value"`
}

Parameter is part of a few method's outputs.

type PerScriptStatus

type PerScriptStatus struct {
	Name   string       `json:"Name"`
	Status ScriptStatus `json:"Status"`
}

PerScriptStatus is part of the history endpoint output.

type ScriptStatus

type ScriptStatus string

ScriptStatus determines the result of a post-processing script.

const (
	ScriptNONE    ScriptStatus = "NONE"
	ScriptFAILURE ScriptStatus = "FAILURE"
	ScriptSUCCESS ScriptStatus = "SUCCESS"
)

ScriptStatuses go here.

type ServerStats

type ServerStats struct {
	ServerID        int64 `json:"ServerID"`
	SuccessArticles int64 `json:"SuccessArticles"`
	FailedArticles  int64 `json:"FailedArticles"`
}

ServerStats is part of a few endpoints output.

type ServerVolume added in v0.1.1

type ServerVolume struct {
	ServerID        int64      `json:"ServerID"`        // ID of news server.
	DataTime        Time       `json:"DataTime"`        // Date/time when the data was last updated (time is in C/Unix format).
	TotalSizeLo     int64      `json:"TotalSizeLo"`     // Total amount of downloaded data since program installation, low 32-bits of 64-bit value.
	TotalSizeHi     int64      `json:"TotalSizeHi"`     // Total amount of downloaded data since program installation, high 32-bits of 64-bit value.
	TotalSizeMB     int64      `json:"TotalSizeMB"`     // Total amount of downloaded data since program installation, in megabytes.
	CustomSizeLo    int64      `json:"CustomSizeLo"`    // Amount of downloaded data since last reset of custom counter, low 32-bits of 64-bit value.
	CustomSizeHi    int64      `json:"CustomSizeHi"`    // Amount of downloaded data since last reset of custom counter, high 32-bits of 64-bit value.
	CustomSizeMB    int64      `json:"CustomSizeMB"`    // Amount of downloaded data since last reset of custom counter, in megabytes.
	CustomTime      Time       `json:"CustomTime"`      // Date/time of the last reset of custom counter (time is in C/Unix format).
	BytesPerSeconds []BytesPer `json:"BytesPerSeconds"` // Per-second amount of data downloaded in last 60 seconds. See below.
	BytesPerMinutes []BytesPer `json:"BytesPerMinutes"` // Per-minute amount of data downloaded in last 60 minutes. See below.
	BytesPerHours   []BytesPer `json:"BytesPerHours"`   // Per-hour amount of data downloaded in last 24 hours. See below.
	BytesPerDays    []BytesPer `json:"BytesPerDays"`    // Per-day amount of data downloaded since program installation. See below.
	SecSlot         int64      `json:"SecSlot"`         // The current second slot of field BytesPerSeconds the program writes into.
	MinSlot         int64      `json:"MinSlot"`         // The current minute slot of field BytesPerMinutes the program writes into.
	HourSlot        int64      `json:"HourSlot"`        // The current hour slot of field BytesPerHours the program writes into.
	DaySlot         int64      `json:"DaySlot"`         // The current day slot of field BytesPerDays the program writes into.
	FirstDay        int64      `json:"FirstDay"`        // Indicates which calendar day the very first slot of BytesPerDays corresponds to. Details see below.
}

ServerVolume represents the servervolumes RPC endpoint output.

type Status

type Status struct {
	RemainingSizeLo     int64         `json:"RemainingSizeLo"`
	RemainingSizeHi     int64         `json:"RemainingSizeHi"`
	RemainingSizeMB     int64         `json:"RemainingSizeMB"`
	ForcedSizeLo        int64         `json:"ForcedSizeLo"`
	ForcedSizeHi        int64         `json:"ForcedSizeHi"`
	ForcedSizeMB        int64         `json:"ForcedSizeMB"`
	DownloadedSizeLo    int64         `json:"DownloadedSizeLo"`
	DownloadedSizeHi    int64         `json:"DownloadedSizeHi"`
	DownloadedSizeMB    int64         `json:"DownloadedSizeMB"`
	MonthSizeLo         int64         `json:"MonthSizeLo"`
	MonthSizeHi         int64         `json:"MonthSizeHi"`
	MonthSizeMB         int64         `json:"MonthSizeMB"`
	DaySizeLo           int64         `json:"DaySizeLo"`
	DaySizeHi           int64         `json:"DaySizeHi"`
	DaySizeMB           int64         `json:"DaySizeMB"`
	ArticleCacheLo      int64         `json:"ArticleCacheLo"`
	ArticleCacheHi      int64         `json:"ArticleCacheHi"`
	ArticleCacheMB      int64         `json:"ArticleCacheMB"`
	DownloadRate        int64         `json:"DownloadRate"`
	AverageDownloadRate int64         `json:"AverageDownloadRate"`
	DownloadLimit       int64         `json:"DownloadLimit"`
	ThreadCount         int64         `json:"ThreadCount"`
	PostJobCount        int64         `json:"PostJobCount"`
	URLCount            int64         `json:"UrlCount"`
	UpTimeSec           int64         `json:"UpTimeSec"`
	DownloadTimeSec     int64         `json:"DownloadTimeSec"`
	FreeDiskSpaceLo     int64         `json:"FreeDiskSpaceLo"`
	FreeDiskSpaceHi     int64         `json:"FreeDiskSpaceHi"`
	FreeDiskSpaceMB     int64         `json:"FreeDiskSpaceMB"`
	ServerTime          Time          `json:"ServerTime"`
	ResumeTime          Time          `json:"ResumeTime"`
	QueueScriptCount    int64         `json:"QueueScriptCount"`
	FeedActive          bool          `json:"FeedActive"`
	DownloadPaused      bool          `json:"DownloadPaused"`
	ServerStandBy       bool          `json:"ServerStandBy"`
	PostPaused          bool          `json:"PostPaused"`
	ScanPaused          bool          `json:"ScanPaused"`
	QuotaReached        bool          `json:"QuotaReached"`
	NewsServers         []NewsServers `json:"NewsServers"`
}

Status represents the status RPC endpoint.

type Time

type Time struct {
	time.Time
}

Time defines a timestamp encoded as epoch seconds in JSON. NZBGet returns all times as seconds since epoch, so we use a custom type to always return a proper go Time.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON is used to convert the timestamp to JSON.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(s []byte) error

UnmarshalJSON is used to convert the timestamp from JSON.

type URLStatus

type URLStatus string

URLStatus determines the result of the URL download.

const (
	URLNONE        URLStatus = "NONE"         // that nzb-file were not fetched from an URL;
	URLSUCCESS     URLStatus = "SUCCESS"      // that nzb-file was fetched from an URL;
	URLFAILURE     URLStatus = "FAILURE"      // the fetching of the URL has failed.
	URLSCANSKIPPED URLStatus = "SCAN_SKIPPED" // The URL was fetched successfully but downloaded file was not nzb-file and was skipped by the scanner;
	URLSCANFAILURE URLStatus = "SCAN_FAILURE" // The URL was fetched successfully but an error occurred during scanning of the downloaded file. The downloaded file isn’t a proper nzb-file. This status usually means the web-server has returned an error page (HTML page) instead of the nzb-file.
)

URLStatuses go here.

type UnpackStatus

type UnpackStatus string

UnpackStatus determines the result of the unpack extraction.

const (
	UnpackNONE     UnpackStatus = "NONE"     // unpack wasn’t performed, either no archive files were found or the unpack is disabled for that download or globally;
	UnpackFAILURE  UnpackStatus = "FAILURE"  // unpack has failed;
	UnpackSPACE    UnpackStatus = "SPACE"    // unpack has failed due to not enough disk space;
	UnpackPASSWORD UnpackStatus = "PASSWORD" // unpack has failed because the password was not provided or was wrong. Only for rar5-archives;
	UnpackSUCCESS  UnpackStatus = "SUCCESS"  // unpack was successful.
)

UnpackStatuses go here.

Jump to

Keyboard shortcuts

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