nzb

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrArticleNotFound = errors.New("article not found")

ErrArticleNotFound indicates a 430 response from Usenet

View Source
var ErrHeaderNotFound = errors.New("yenc header not found")

Functions

func GetCategoryName added in v0.5.0

func GetCategoryName(id string) string

GetCategoryName maps Newsnab IDs to human-readable strings.

Types

type Article added in v0.4.0

type Article struct {
	MessageID string
	Size      int
}

Article respresents the metadata for a single Usenet post.

type ArticleRespository added in v0.4.0

type ArticleRespository interface {
	FetchBody(messageID string) (io.Reader, error)
	Authenticate() error
	Close() error
}

ArticleRepository defines the contract for fetching data from Usenet.

type File added in v0.4.0

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

type Meta added in v0.4.1

type Meta struct {
	Type    string `xml:"type,attr"`
	Content string `xml:",chardata"`
}

type Model added in v0.4.0

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

func (*Model) GetPassword added in v0.4.1

func (n *Model) GetPassword() string

Helper method to grab the password from the slice of Meta tags

type Parser

type Parser struct{}

func NewParser

func NewParser() *Parser

func (*Parser) Parse

func (p *Parser) Parse(r io.Reader) (*Model, error)

func (*Parser) ParseFile

func (p *Parser) ParseFile(nzbPath string) (*Model, error)

type Segment added in v0.4.0

type Segment struct {
	XMLName   xml.Name `xml:"segment"`
	Number    int      `xml:"number,attr"`
	Bytes     int64    `xml:"bytes,attr"`
	MessageID string   `xml:",chardata"`
}

type YencDecoder added in v0.4.0

type YencDecoder struct {
	PartNumber int
	TotalParts int
	PartOffset int64
	FileSize   int64
	FileName   string
	// contains filtered or unexported fields
}

func NewYencDecoder added in v0.4.0

func NewYencDecoder(r io.Reader) *YencDecoder

func (*YencDecoder) DiscardHeader added in v0.4.0

func (d *YencDecoder) DiscardHeader() error

func (*YencDecoder) Read added in v0.4.0

func (d *YencDecoder) Read(p []byte) (n int, err error)

func (*YencDecoder) Verify added in v0.4.0

func (d *YencDecoder) Verify() error

type YencHeader added in v0.7.0

type YencHeader struct {
	PartNumber int
	TotalParts int
	PartOffset int64
	FileSize   int64
	FileName   string
}

func ReadYencHeader added in v0.7.0

func ReadYencHeader(r io.Reader) (YencHeader, error)

Jump to

Keyboard shortcuts

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