newznab

package
v0.0.0-...-6079cd8 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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, debug bool, limitercalls int, limiterseconds int) Client

New returns a new instance of Client

func (Client) BuildRssUrl

func (c Client) BuildRssUrl(customrssurl string, customrsscategory string, customapi string, additional_query_params string, num int, categories []int, offset int, outputasjson bool) string

func (Client) LoadRSSFeed

func (c Client) LoadRSSFeed(categories []int, num int, additional_query_params string, customapi string, customrssurl string, customrsscategory string, maxage int, outputasjson bool) ([]NZB, error)

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

func (Client) LoadRSSFeedUntilNZBID

func (c Client) LoadRSSFeedUntilNZBID(categories []int, num int, id string, maxRequests int, additional_query_params string, customapi string, customrssurl string, customrsscategory string, maxage int, outputasjson bool) ([]NZB, error)

LoadRSSFeedUntilNZBID fetches NZBs until a given NZB id is reached.

func (Client) SearchWithIMDB

func (c Client) SearchWithIMDB(categories []int, imdbID string, additional_query_params string, customurl string, maxage int, outputasjson bool) ([]NZB, error)

SearchWithIMDB returns NZBs for the given parameters

func (Client) SearchWithQuery

func (c Client) SearchWithQuery(categories []int, query string, searchType string, addquotes bool, additional_query_params string, customurl string, maxage int, outputasjson bool) ([]NZB, error)

SearchWithQuery returns NZBs for the given parameters

func (Client) SearchWithQueryUntilNZBID

func (c Client) SearchWithQueryUntilNZBID(categories []int, query string, searchType string, addquotes bool, id string, additional_query_params string, customurl string, maxage int, outputasjson bool) ([]NZB, error)

LoadRSSFeedUntilNZBID fetches NZBs until a given NZB id is reached.

func (Client) SearchWithTVDB

func (c Client) SearchWithTVDB(categories []int, tvDBID int, season int, episode int, additional_query_params string, customurl string, maxage int, outputasjson bool) ([]NZB, error)

SearchWithTVDB returns NZBs for the given parameters

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"`

	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"`
	Poster     string `json:"poster,omitempty"`
	Group      string `json:"group,omitempty"`

	// TV Specific stuff
	TVDBID  string `json:"tvdbid,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

type RLHTTPClient

type RLHTTPClient struct {
	Ratelimiter   *rate.Limiter
	LimiterWindow *slidingwindow.Limiter
	// contains filtered or unexported fields
}

RLHTTPClient Rate Limited HTTP Client

func NewRlClient

func NewRlClient(rl *rate.Limiter, rl2 *slidingwindow.Limiter) *RLHTTPClient

NewClient return http client with a ratelimiter

func (*RLHTTPClient) DoJson

func (c *RLHTTPClient) DoJson(url string) (string, interface{}, error)

Do dispatches the HTTP request to the network

func (*RLHTTPClient) DoXml

func (c *RLHTTPClient) DoXml(url string, xmlobj interface{}) error

Do dispatches the HTTP request to the network

type RawNZB

type RawNZB struct {
	Title string `xml:"title,omitempty"`
	Link  string `xml:"link,omitempty"`
	Size  int64  `xml:"size,omitempty"`

	GUID struct {
		GUID string `xml:",chardata"`
	} `xml:"guid,omitempty"`

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

	Date string `xml:"pubDate,omitempty"`

	Enclosure struct {
		URL string `xml:"url,attr"`
	} `xml:"enclosure,omitempty"`

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

RawNZB represents a single NZB item in search results.

type RawNZBJson1

type RawNZBJson1 struct {
	Title     string `json:"title,omitempty"`
	Link      string `json:"link,omitempty"`
	Guid      string `json:"guid,omitempty"`
	Size      int64  `json:"size,omitempty"`
	Date      string `json:"pubDate,omitempty"`
	Enclosure struct {
		Attributes struct {
			URL string `json:"url"`
		} `json:"@attributes,omitempty"`
	} `json:"enclosure,omitempty"`

	Attributes []struct {
		Attribute struct {
			Name  string `json:"name"`
			Value string `json:"value"`
		} `json:"@attributes,omitempty"`
	} `json:"attr,omitempty"`
}

type RawNZBJson2

type RawNZBJson2 struct {
	Title string `json:"title,omitempty"`
	Link  string `json:"link,omitempty"`
	Size  int64  `json:"size,omitempty"`
	GUID  struct {
		GUID string `json:"text,omitempty"`
	} `json:"guid,omitempty"`
	Date      string `json:"pubDate,omitempty"`
	Enclosure struct {
		URL string `json:"_url"`
	} `json:"enclosure,omitempty"`

	Attributes []struct {
		Name  string `json:"_name"`
		Value string `json:"_value"`
	} `json:"newznab:attr,omitempty"`
	Attributes2 []struct {
		Name  string `json:"_name"`
		Value string `json:"_value"`
	} `json:"nntmux:attr,omitempty"`
}

type SearchResponse

type SearchResponse struct {
	NZBs []RawNZB `xml:"channel>item"`
}

SearchResponse is a RSS version of the response.

type SearchResponseJson1

type SearchResponseJson1 struct {
	Title   string `json:"title,omitempty"`
	Channel struct {
		Item []RawNZBJson1 `json:"item"`
	} `json:"channel"`
}

type SearchResponseJson2

type SearchResponseJson2 struct {
	Item []RawNZBJson2 `json:"item"`
}

Jump to

Keyboard shortcuts

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