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" // xml namespace for nzb files Xmlns = "http://www.newzbin.com/DTD/2003/nzb" )
Variables ¶
This section is empty.
Functions ¶
func MakeUnique ¶
func MakeUnique(nzb *Nzb)
clean up nzb files by keeping only the first occurrence of duplicate file entries and removing duplicate segments
Types ¶
type Nzb ¶
type Nzb struct {
Comment string // comment tag
Meta map[string]string // meta data as map
Files NzbFiles // files structure
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 ParseStringWithOptions ¶ added in v0.5.0
func ParseStringWithOptions(data string, opts ParseOptions) (*Nzb, error)
parse nzb file provided as string with custom options
func ParseWithOptions ¶ added in v0.5.0
func ParseWithOptions(buf io.Reader, opts ParseOptions) (*Nzb, error)
parse nzb file provided as io.Reader buffer with custom options
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"`
Bytes int64 `xml:"bytes,attr"` // total size of the file
FileHash string `xml:"filehash,attr"` // hash of the file
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
}
individual file structure with additional information
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)
type ParseOptions ¶ added in v0.5.0
type ParseOptions struct {
RemoveDuplicates bool // whether to remove duplicate files and segments
}
ParseOptions allows configuration of the NZB parsing behavior
type Subject ¶ added in v0.4.0
type Subject struct {
Subject string // full subject
Header string // header (remaining text before the filename)
Filename string // filename with extension (in the subject it is usually between quotes)
Basefilename string // filename without extension(s)
File int // number of the file in the file set (=X in [X/Y])
TotalFiles int // number of total files in the file set (=Y in [X/Y])
Segment int // number of the segment of this file (=X in (X/Y))
TotalSegments int // number of total segments for this file (=Y in (X/Y))
}
func ParseSubject ¶ added in v0.4.0
the Parse method analyses a given string and returns the Subject structure
Click to show internal directories.
Click to hide internal directories.