Documentation ¶
Index ¶
Constants ¶
const ( EZTVBaseURL = "https://eztv.re/api" StreamRecheckInterval = 5 * time.Minute MaxEZTVAPILimit = 100 )
Variables ¶
var ErrMissingImdbID = errors.New("missing imdbID")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the EZTV API client. It can make requests to the EZTV API to retrieve data.
func New ¶
New returns a new Client with a default http.Client.
Custom options can be passed to set different behaviour.
func (*Client) GetTorrents ¶
GetTorrents returns a Page of torrents from the EZTV API.
URLOptions allow to customize the data that is retrieved. API has a hard limit of max 100 torrents per page. More than that will default to 30.
func (*Client) TorrentStream ¶
func (c *Client) TorrentStream(ctx context.Context, streamOptions StreamOptions) <-chan StreamTorrent
TorrentStream returns a channel that will push new torrents as they are added to the EZTV API.
StreamOptions allow to specify LastTorrentID from which to start the stream. If LastTorrentID is 0, it will do a full re-sync of all torrents for the given ImdbID.
If no ImdID is specified, it will return ErrMissingImdbID error from stream and close it.
If no RecheckInterval is specified, it will default to StreamRecheckInterval constant.
type Option ¶
type Option func(*Client)
func WithBaseURL ¶
WithBaseURL sets the base URL that will be used to make requests.
func WithHTTPClient ¶
WithHTTPClient sets the http.Client that will be used to make requests.
type StreamOptions ¶
type StreamOptions struct { // Specifies what shows torrents to fetch. ImdbID string // Specifies from which torrent ID to start the stream. LastTorrentID int // Specifies how often to re-check for new torrents. RecheckInterval time.Duration }
StreamOptions allow to customize the behaviour of the TorrentStream.
type StreamTorrent ¶
type Torrent ¶
type Torrent struct { ID int `json:"id"` Hash string `json:"hash"` Filename string `json:"filename"` EpisodeURL string `json:"episode_url"` TorrentURL string `json:"torrent_url"` MagnetURL string `json:"magnet_url"` Title string `json:"title"` ImdbID string `json:"imdb_id"` Season string `json:"season"` Episode string `json:"episode"` SmallScreenshotURL string `json:"small_screenshot"` LargeScreenshotURL string `json:"large_screenshot"` Seeds int `json:"seeds"` Peers int `json:"peers"` DateReleasedUnix int `json:"date_released_unix"` SizeBytes string `json:"size_bytes"` }
type URLOptions ¶
type URLOptions struct { // Specifies the page number to retrieve. Default is 1. Page int // Specifies the number of torrents to retrieve. Default is 30. // API has a hard limit of 100 torrents per page and minimum limit of 1. Limit int // ImdbID tag will retrieve torrents only for that exact show. ImdbID string }
URLOptions are the options that can be passed into EZTV API for custom data retrieval.