newznab

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TV Categories
	// CategoryTVAll is for all shows
	CategoryTVAll = 5000
	// CategoryTVForeign is for foreign shows
	CategoryTVForeign = 5020
	// CategoryTVSD is for standard-definition shows
	CategoryTVSD = 5030
	// CategoryTVHD is for high-definition shows
	CategoryTVHD = 5040
	// CategoryTVUHD is for UHD shows
	CategoryTVUHD = 5045
	// CategoryTVOther is for other shows
	CategoryTVOther = 5050
	// CategoryTVSport is for sports shows
	CategoryTVSport = 5060

	// Movie categories
	// CategoryMovieAll is for all movies
	CategoryMovieAll = 2000
	// CategoryMovieForeign is for foreign movies
	CategoryMovieForeign = 2010
	// CategoryMovieOther is for other movies
	CategoryMovieOther = 2020
	// CategoryMovieSD is for standard-definition movies
	CategoryMovieSD = 2030
	// CategoryMovieHD is for high-definition movies
	CategoryMovieHD = 2040
	// CategoryMovieUHD is for UHD movies
	CategoryMovieUHD = 2045
	// CategoryMovieBluRay is for blu-ray movies
	CategoryMovieBluRay = 2050
	// CategoryMovie3D is for 3-D movies
	CategoryMovie3D = 2060
)

Various constants for categories

Variables

This section is empty.

Functions

This section is empty.

Types

type Capabilities added in v1.1.0

type Capabilities struct {
	Server struct {
		Title string `xml:"title,attr" json:"title,omitempty"`
	} `xml:"server" json:"server,omitempty"`
	Searching struct {
		Search struct {
			Available       string `xml:"available,attr" json:"available,omitempty"`
			SupportedParams string `xml:"supportedParams,attr" json:"supported_params,omitempty"`
		} `xml:"search" json:"search,omitempty"`
		TvSearch struct {
			Available       string `xml:"available,attr" json:"available,omitempty"`
			SupportedParams string `xml:"supportedParams,attr" json:"supported_params,omitempty"`
		} `xml:"tv-search" json:"tv_search,omitempty"`
		MovieSearch struct {
			Available       string `xml:"available,attr" json:"available,omitempty"`
			SupportedParams string `xml:"supportedParams,attr" json:"supported_params,omitempty"`
		} `xml:"movie-search" json:"movie_search,omitempty"`
	} `xml:"searching" json:"searching,omitempty"`
	Categories struct {
		Category []struct {
			ID     string `xml:"id,attr" json:"id,omitempty"`
			Name   string `xml:"name,attr" json:"name,omitempty"`
			Subcat []struct {
				ID   string `xml:"id,attr" json:"id,omitempty"`
				Name string `xml:"name,attr" json:"name,omitempty"`
			} `xml:"subcat" json:"subcat,omitempty"`
		} `xml:"category" json:"category,omitempty"`
	} `xml:"categories" json:"categories,omitempty"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a type for interacting with a newznab or torznab api

func New

func New(baseURL string, apikey string, userID int, insecure bool) Client

New returns a new instance of Client

func (Client) Capabilities added in v1.1.0

func (c Client) Capabilities() (Capabilities, error)

Capabilities returns the capabilities of this tracker

func (Client) Details added in v1.2.0

func (c Client) Details(guid string) (Details, error)

Details get the details of a particular nzb

func (Client) DownloadNZB

func (c Client) DownloadNZB(nzb NZB) ([]byte, error)

DownloadNZB returns the bytes of the actual NZB file for the given NZB

func (Client) LoadRSSFeed added in v0.3.0

func (c Client) LoadRSSFeed(categories []int, num int) ([]NZB, error)

LoadRSSFeed returns up to <num> of the most recent NZBs of the given categories.

func (Client) LoadRSSFeedUntilNZBID added in v0.3.0

func (c Client) LoadRSSFeedUntilNZBID(categories []int, num int, id string, maxRequests int) ([]NZB, error)

LoadRSSFeedUntilNZBID fetches NZBs until a given NZB id is reached.

func (Client) NZBDownloadURL

func (c Client) NZBDownloadURL(nzb NZB) (string, error)

NZBDownloadURL returns a URL to download the NZB from

func (Client) PopulateComments

func (c Client) PopulateComments(nzb *NZB) error

PopulateComments fills in the Comments for the given NZB

func (Client) SearchWithIMDB added in v0.2.0

func (c Client) SearchWithIMDB(categories []int, imdbID string) ([]NZB, error)

SearchWithIMDB returns NZBs for the given parameters

func (Client) SearchWithQuery

func (c Client) SearchWithQuery(categories []int, query string, searchType string) ([]NZB, error)

SearchWithQuery returns NZBs for the given parameters

func (Client) SearchWithTVDB added in v0.2.0

func (c Client) SearchWithTVDB(categories []int, tvDBID int, season int, episode int) ([]NZB, error)

SearchWithTVDB returns NZBs for the given parameters

func (Client) SearchWithTVMaze added in v1.1.0

func (c Client) SearchWithTVMaze(categories []int, tvMazeID int, season int, episode int) ([]NZB, error)

SearchWithTVMaze returns NZBs for the given parameters

func (Client) SearchWithTVRage

func (c Client) SearchWithTVRage(categories []int, tvRageID int, season int, episode int) ([]NZB, error)

SearchWithTVRage returns NZBs for the given parameters

type Comment

type Comment struct {
	Title   string    `json:"title,omitempty"`
	Content string    `json:"content,omitempty"`
	PubDate time.Time `json:"pub_date,omitempty"`
}

Comment represents a user comment left on an NZB record

func (Comment) JSONString

func (c Comment) JSONString() string

JSONString returns a JSON string representation of this Comment

type Details added in v1.2.0

type Details struct {
	XMLName xml.Name `xml:"rss"`
	Text    string   `xml:",chardata"`
	Version string   `xml:"version,attr"`
	Channel struct {
		Text string `xml:",chardata"`
		Item struct {
			Text  string `xml:",chardata"`
			Title string `xml:"title"`
			Guid  struct {
				Text        string `xml:",chardata"`
				IsPermaLink string `xml:"isPermaLink,attr"`
			} `xml:"guid"`
			Link        string `xml:"link"`
			Comments    string `xml:"comments"`
			PubDate     string `xml:"pubDate"`
			Category    string `xml:"category"`
			Description string `xml:"description"`
			Enclosure   struct {
				Text   string `xml:",chardata"`
				URL    string `xml:"url,attr"`
				Length string `xml:"length,attr"`
				Type   string `xml:"type,attr"`
			} `xml:"enclosure"`
			Attr []struct {
				Text  string `xml:",chardata"`
				Name  string `xml:"name,attr"`
				Value string `xml:"value,attr"`
			} `xml:"attr"`
		} `xml:"item"`
	} `xml:"channel"`
}

type NZB

type NZB struct {
	ID          string    `json:"id,omitempty"`
	Title       string    `json:"title,omitempty"`
	Description string    `json:"description,omitempty"`
	Size        int64     `json:"size,omitempty"`
	AirDate     time.Time `json:"air_date,omitempty"`
	PubDate     time.Time `json:"pub_date,omitempty"`
	UsenetDate  time.Time `json:"usenet_date,omitempty"`
	NumGrabs    int       `json:"num_grabs,omitempty"`
	NumComments int       `json:"num_comments,omitempty"`
	Comments    []Comment `json:"comments,omitempty"`

	SourceEndpoint string `json:"source_endpoint"`
	SourceAPIKey   string `json:"source_apikey"`

	Category []string `json:"category,omitempty"`
	Info     string   `json:"info,omitempty"`
	Genre    string   `json:"genre,omitempty"`

	Resolution string `json:"resolution,omitempty"`

	// TV Specific stuff
	TVDBID   string `json:"tvdbid,omitempty"`
	TVRageID string `json:"tvrageid,omitempty"`
	TVMazeID string `json:"tvmazeid,omitempty"`
	Season   string `json:"season,omitempty"`
	Episode  string `json:"episode,omitempty"`
	TVTitle  string `json:"tvtitle,omitempty"`
	Rating   int    `json:"rating,omitempty"`

	// Movie Specific stuff
	IMDBID    string  `json:"imdb,omitempty"`
	IMDBTitle string  `json:"imdbtitle,omitempty"`
	IMDBYear  int     `json:"imdbyear,omitempty"`
	IMDBScore float32 `json:"imdbscore,omitempty"`
	CoverURL  string  `json:"coverurl,omitempty"`

	// Torznab specific stuff
	Seeders     int    `json:"seeders,omitempty"`
	Peers       int    `json:"peers,omitempty"`
	InfoHash    string `json:"infohash,omitempty"`
	DownloadURL string `json:"download_url,omitempty"`
	IsTorrent   bool   `json:"is_torrent,omitempty"`
}

NZB represents an NZB found on the index

func (NZB) JSONString

func (n NZB) JSONString() string

JSONString returns a JSON string representation of this NZB

type RawNZB

type RawNZB struct {
	Title    string `xml:"title,omitempty"`
	Link     string `xml:"link,omitempty"`
	Size     int64  `xml:"size,omitempty"`
	Category struct {
		Domain string `xml:"domain,attr"`
		Value  string `xml:",chardata"`
	} `xml:"category,omitempty"`

	GUID struct {
		GUID        string `xml:",chardata"`
		IsPermaLink bool   `xml:"isPermaLink,attr"`
	} `xml:"guid,omitempty"`

	Comments    string `xml:"comments"`
	Description string `xml:"description"`
	Author      string `xml:"author,omitempty"`

	Source struct {
		URL   string `xml:"url,attr"`
		Value string `xml:",chardata"`
	} `xml:"source,omitempty"`

	Date Time `xml:"pubDate,omitempty"`

	Enclosure struct {
		URL    string `xml:"url,attr"`
		Length string `xml:"length,attr"`
		Type   string `xml:"type,attr"`
	} `xml:"enclosure,omitempty"`

	Attributes []struct {
		XMLName xml.Name
		Name    string `xml:"name,attr"`
		Value   string `xml:"value,attr"`
	} `xml:"attr"`
}

RawNZB represents a single NZB item in search results.

type SearchResponse

type SearchResponse struct {
	Version   string `xml:"version,attr"`
	ErrorCode int    `xml:"code,attr"`
	ErrorDesc string `xml:"description,attr"`
	Channel   struct {
		Title string `xml:"title"`
		Link  struct {
			Href string `xml:"href,attr"`
			Rel  string `xml:"rel,attr"`
			Type string `xml:"type,attr"`
		} `xml:"http://www.w3.org/2005/Atom link"`
		Description string `xml:"description"`
		Language    string `xml:"language,omitempty"`
		Webmaster   string `xml:"webmaster,omitempty"`
		Category    string `xml:"category,omitempty"`
		Image       struct {
			URL         string `xml:"url"`
			Title       string `xml:"title"`
			Link        string `xml:"link"`
			Description string `xml:"description,omitempty"`
			Width       int    `xml:"width,omitempty"`
			Height      int    `xml:"height,omitempty"`
		} `xml:"image"`

		Response struct {
			Offset int `xml:"offset,attr"`
			Total  int `xml:"total,attr"`
		} `xml:"http://www.newznab.com/DTD/2010/feeds/attributes/ response"`

		// All NZBs that match the search query, up to the response limit.
		NZBs []RawNZB `xml:"item"`
	} `xml:"channel"`
}

SearchResponse is a RSS version of the response.

type Time

type Time struct {
	time.Time
}

func (*Time) MarshalXML

func (t *Time) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Time) UnmarshalXML

func (t *Time) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

Jump to

Keyboard shortcuts

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