https://github.com/andrewstuart/go-nzb
Golang nzb parsing
https://github.com/andrewstuart/go-nzb
Last synced: about 1 year ago
JSON representation
Golang nzb parsing
- Host: GitHub
- URL: https://github.com/andrewstuart/go-nzb
- Owner: andrewstuart
- License: mit
- Created: 2015-07-25T20:01:01.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-11-30T21:34:24.000Z (over 10 years ago)
- Last Synced: 2025-02-03T06:41:57.467Z (over 1 year ago)
- Language: Go
- Size: 70.3 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nzb
[](https://godoc.org/github.com/andrewstuart/go-nzb)
--
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
```go
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
```go
func (f *File) Name() (string, error)
```
Name returns the estimated filename that an NZB represents.
#### type Meta
```go
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
```go
func (m *Meta) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
```
UnmarshalXML implements xml.Unmarshaler
#### type NZB
```go
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
```go
func (nzb *NZB) Size() uint64
```
Size returns the sum of the file sizes within the nzb.
#### type Segment
```go
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