nzb

package module
v0.0.0-...-4af25f1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2015 License: MIT Imports: 4 Imported by: 3

README

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

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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"`
	// contains filtered or unexported fields
}

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

Jump to

Keyboard shortcuts

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