Documentation ¶
Overview ¶
Package torrentapi provides simple and easy Golang interface for RARBG Torrent API v2 (https://torrentapi.org)
Index ¶
- Constants
- type API
- func (a *API) Category(category int) *API
- func (a *API) Format(format string) *API
- func (a *API) Limit(limit int) *API
- func (a *API) List() (TorrentResults, error)
- func (a *API) MinLeechers(minLeech int) *API
- func (a *API) MinSeeders(minSeed int) *API
- func (a *API) Ranked(ranked bool) *API
- func (a *API) Search() (TorrentResults, error)
- func (a *API) SearchString(query string) *API
- func (a *API) Sort(sort string) *API
- type APIResponse
- type EpisodeInfo
- type Option
- type Token
- type TorrentResult
- type TorrentResults
Constants ¶
const ( // Version of supported torrentapi. Version = 2.0 // DefaultAPIURL is a default value for APIURL option. DefaultAPIURL = "https://torrentapi.org/pubapi_v2.php?" // Defaulta.tokenExpiration is a default value for TokenExpiration option // (TorrentAPI exprires after 15 min, but let's expire it after 890 seconds // just to be safe. DefaultTokenExpiration = time.Second * 890 // DefaultRequestDelay is a default delay between requests. DefaultRequestDelay = time.Second * 2 // DefaultMaxRetries is a default value for MaxRetries option. DefaultMaxRetries = 10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
API provides interface to access Torrent API.
func (*API) Format ¶
Format requests different results format, possible values json, json_extended. Please note that whith json format not all fields are populated in TorrentResult.
func (*API) List ¶
func (a *API) List() (TorrentResults, error)
List lists the newest torrrents, this has to be last function in chain.
func (*API) MinLeechers ¶
MinLeechers specify minimum number of leechers.
func (*API) MinSeeders ¶
MinSeeders specify minimum number of seeders.
func (*API) Search ¶
func (a *API) Search() (TorrentResults, error)
Search performs search, this has to be last function in chain.
func (*API) SearchString ¶
SearchString adds search string to search query.
type APIResponse ¶
type APIResponse struct { Error string `json:"error"` ErrorCode int `json:"error_code"` Torrents json.RawMessage `json:"torrent_results"` }
APIResponse from Torrent API.
type EpisodeInfo ¶
type EpisodeInfo struct { AirDate string `json:"airdate"` EpisodeNum string `json:"epnum"` ImDB string `json:"imdb"` SeasonNum string `json:"seasonnum"` TheMovieDb string `json:"themoviedb"` Title string `json:"title"` TvDB string `json:"tvdb"` TvRage string `json:"tvrage"` }
EpisodeInfo keepsinformation from "episode_info" key from results. Some of the fields may be empty.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is an interface used to set various options for API.
func MaxRetries ¶
MaxRetries sets maximum retries after 429 Too Many Requests response.
func RequestDelay ¶
RequestDelay sets delay between requests.
func TokenExpiration ¶
TokenExpiration sets time after token expires.
type TorrentResult ¶
type TorrentResult struct { Category string `json:"category"` Download string `json:"download"` EpisodeInfo EpisodeInfo `json:"episode_info"` Filename string `json:"filename"` InfoPage string `json:"info_page"` Leechers int `json:"leechers"` PubDate string `json:"pubdate"` Ranked int `json:"ranked"` Seeders int `json:"seeders"` Size uint64 `json:"size"` Title string `json:"title"` }
TorrentResult keeps information about single torrent returned from TorrentAPI. Some of the fields may be empty.
type TorrentResults ¶
type TorrentResults []TorrentResult
TorrentResults represents multiple results.