Documentation
¶
Overview ¶
Package newznab is a dependency-free client for the Newznab indexer API.
It targets the Newznab Usenet search API and also works against NZBHydra2, which exposes a Newznab-superset API. The client is CGO-free and uses only the Go standard library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// BaseURL is the indexer root, e.g. https://api.nzbgeek.info.
BaseURL string
// APIKey is the indexer API key.
APIKey string
// HTTPClient is used for all requests. Defaults to http.DefaultClient.
HTTPClient *http.Client
// UserAgent is sent on every request.
UserAgent string
}
Client is a Newznab / NZBHydra2 API client.
func (*Client) Capabilities ¶
Capabilities performs a t=caps query and returns the category tree.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, opts SearchOptions) (*SearchResult, error)
Search performs a t=search query against the indexer.
type Item ¶
type Item struct {
Title string
GUID string
NZBURL string // the .nzb download link (item <link> or <enclosure url>)
Category string
Size int64 // bytes (from newznab:attr name="size" or <enclosure length>)
PublishDate time.Time // <pubDate>, RFC1123Z
Group string // newznab:attr name="group" (may be empty)
Poster string // newznab:attr name="poster" (may be empty)
Grabs int // newznab:attr name="grabs" (0 if absent)
}
Item is a single search result.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithHTTPClient ¶
WithHTTPClient sets a custom *http.Client.
func WithUserAgent ¶
WithUserAgent sets a custom User-Agent header.
type SearchOptions ¶
type SearchOptions struct {
Query string
Categories []int // newznab category ids
Group string // limit to a newsgroup
Limit int
Offset int
}
SearchOptions parameterises a Search call.
type SearchResult ¶
type SearchResult struct {
Items []Item
Total int // from <newznab:response total=...> when present, else len(Items)
Offset int
}
SearchResult is the outcome of a Search call.