The Central Go Modules Repository

To use GoCenter:
export GOPROXY=https://gocenter.io
3
Stars
MIT
License
4
Downloads
September 20th 2016
Last Modified
Version:
Loading...

nzb

GoDoc

– import “github.com/andrewstuart/go-nzb”

Package nzb is intended to be a library that basically just provides go structs that one can unmarshall an NZB file into and have enough information to locate the associated files on usenet.

Usage

type File

type File struct {
	Poster   string    `xml:"poster,attr"`
	Date     int       `xml:"date,attr"`
	Subject  string    `xml:"subject,attr"`
	Groups   []string  `xml:"groups>group,internalxml"`
	Segments []Segment `xml:"segments>segment"`
}

File is a go struct representation of the nzb file elements. It contains the appropriate field tags and methods for deserialization

func (*File) Name

func (f *File) Name() (string, error)

Name returns the estimated filename that an NZB represents.

type Meta

type Meta map[string]string

The Meta type is simply a map[string]string that implements UnmarshalXML to appropriately unmarshal the xml metadata tags.

func (*Meta) UnmarshalXML

func (m *Meta) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements xml.Unmarshaler

type NZB

type NZB struct {
	XMLName xml.Name `xml:"nzb"`
	Meta    Meta     `xml:"head>meta"`
	Files   []File   `xml:"file"`
}

NZB is a go struct representation of an nzb file with the appropriate tags and methods for XML unmarshalling.

func (*NZB) Size

func (nzb *NZB) Size() uint64

Size returns the sum of the file sizes within the nzb.

type Segment

type Segment struct {
	Number int    `xml:"number,attr"`
	Bytes  int    `xml:"bytes,attr"`
	ID     string `xml:",innerxml"`
}

A Segment is a piece to be downloaded separately