nzbparser

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// xml header for nzb files
	Header = `<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE nzb PUBLIC "-//newzBin//DTD NZB 1.1//EN" "http://www.newzbin.com/DTD/nzb/nzb-1.1.dtd">` + "\n"
)

Variables

This section is empty.

Functions

func MakeUnique

func MakeUnique(nzb *Nzb)

func ScanNzbFile

func ScanNzbFile(nzb *Nzb)

scan the nzb struct for additional information

func Write

func Write(nzb *Nzb) ([]byte, error)

write nzb struct to nzb xml as byte slice

func WriteString

func WriteString(nzb *Nzb) (string, error)

write nzb struct to nzb xml as string

Types

type Nzb

type Nzb struct {
	Comment       string
	Meta          map[string]string // meta data as map
	Files         NzbFiles
	TotalFiles    int   // number of total files
	Segments      int   // number of available segments
	TotalSegments int   // number of total segments
	Bytes         int64 // total size of all files
}

nzb file structure with additional information

func Parse

func Parse(buf io.Reader) (*Nzb, error)

parese nzb file provided as io.Reader buffer

func ParseString

func ParseString(data string) (*Nzb, error)

parse nzb file provided as string

type NzbFile

type NzbFile struct {
	Groups        []string    `xml:"groups>group"`
	Segments      NzbSegments `xml:"segments>segment"`
	Poster        string      `xml:"poster,attr"`
	Date          int         `xml:"date,attr"`
	Subject       string      `xml:"subject,attr"`
	Number        int         `xml:"-"` // number of the file (if indicated in the subject)
	Filename      string      `xml:"-"` // filename of the file (if indicated in the subject)
	Basefilename  string      `xml:"-"` // basefilename of the file (if indicated in the subject)
	TotalSegments int         `xml:"-"` // number of total segments
	Bytes         int64       `xml:"-"` // total size of the file
}

individual file structure with additional information

type NzbFiles

type NzbFiles []NzbFile

a slice of NzbFiles extended to allow sorting

func (NzbFiles) Len

func (s NzbFiles) Len() int

func (NzbFiles) Less

func (s NzbFiles) Less(i, j int) bool

func (NzbFiles) Swap

func (s NzbFiles) Swap(i, j int)

type NzbSegment

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

individual segment structure

type NzbSegments

type NzbSegments []NzbSegment

a slice of NzbSegments extended to allow sorting

func (NzbSegments) Len

func (s NzbSegments) Len() int

func (NzbSegments) Less

func (s NzbSegments) Less(i, j int) bool

func (NzbSegments) Swap

func (s NzbSegments) Swap(i, j int)

Jump to

Keyboard shortcuts

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