Documentation ¶
Index ¶
- Variables
- func SelectLargestFile(status Status) (string, error)
- type Client
- func (c *Client) GetInstantAvailability(ctx context.Context, hashes ...string) (map[string]struct{}, error)
- func (c *Client) GetStatus(ctx context.Context, id int) (Status, error)
- func (c *Client) GetUser(ctx context.Context) (User, error)
- func (c *Client) Unlock(ctx context.Context, link string) (Download, error)
- func (c *Client) UploadMagnet(ctx context.Context, magnet string) (Magnet, error)
- type ClientOptions
- type Download
- type LegacyClient
- type LegacyClientOptions
- type Link
- type Magnet
- type Status
- type StatusCode
- type Stream
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // Bad request. // Corresponds to AllDebrid 400 status code. ErrorBadRequest = errors.New("bad request") // Corresponds to AllDebrid 401 status code. ErrorUnauthorized = errors.New("unauthorized") // Too many requests hit the API too quickly, see https://docs.alldebrid.com/#rate-limiting. // Corresponds to AllDebrid 429 status code. ErrorTooManyRequests = errors.New("too many requests") // Something went wrong on Alldebrid's end. // Corresponds to AllDebrid 500, 502, 503 and 504 status codes. ErrorServerError = errors.New("server error") )
var DefaultClientOpts = ClientOptions{ BaseURL: "https://api.alldebrid.com/v4", Timeout: 5 * time.Second, }
DefaultClientOpts are ClientOptions with reasonable default values.
var DefaultLegacyClientOpts = LegacyClientOptions{ BaseURL: "https://api.alldebrid.com", Timeout: 5 * time.Second, CacheAge: 24 * time.Hour, }
Functions ¶
func SelectLargestFile ¶ added in v0.2.0
SelectLargestFile returns the link of the largest file in the torrent.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a AllDebrid client.
func NewClient ¶
func NewClient(opts ClientOptions, apiKey string, logger *zap.Logger) *Client
NewClient returns a new AllDebrid client. The logger param can be nil.
func (*Client) GetInstantAvailability ¶ added in v0.2.0
func (c *Client) GetInstantAvailability(ctx context.Context, hashes ...string) (map[string]struct{}, error)
GetInstantAvailability fetches and returns info about the instant availability of a torrent. The hashes can actually also be magnet URLs. The returned map contains the hashes / magnet URLs of the torrents that are instantly available.
func (*Client) GetStatus ¶ added in v0.2.0
GetStatus fetches and returns the status of a torrent that was added to AllDebrid for a specific user. The ID must be the one returned from AllDebrid when adding the torrent to AllDebrid.
func (*Client) GetUser ¶ added in v0.2.0
GetUser fetches and returns the user object from AllDebrid.
type ClientOptions ¶
type ClientOptions struct { // Base URL for HTTP requests. This will also be used when making a request to a link that's read from a AllDebrid response by replacing its base URL. BaseURL string // Timeout for HTTP requests Timeout time.Duration // Extra headers to set for HTTP requests ExtraHeaders map[string]string }
ClientOptions are options for the client.
type Download ¶ added in v0.2.0
type Download struct { // Requested link, simplified if it was not in canonical form Link string `json:"link,omitempty"` // Link's file filename Filename string `json:"filename,omitempty"` // Link host minified Host string `json:"host,omitempty"` // List of alternative links with other resolutions for some video links Streams []Stream `json:"streams,omitempty"` // Unused Paws bool `json:"paws,omitempty"` // Filesize of the link's file Filesize int `json:"filesize,omitempty"` // Generation ID ID string `json:"id,omitempty"` // Matched host main domain HostDomain string `json:"hostDomain,omitempty"` // Delayed ID if link need time to generate Delayed int `json:"delayed,omitempty"` }
Download represents an unlocked link.
type LegacyClient ¶ added in v0.2.0
type LegacyClient struct {
// contains filtered or unexported fields
}
func NewLegacyClient ¶ added in v0.2.0
func NewLegacyClient(opts LegacyClientOptions, apiKeyCache, availabilityCache debrid.Cache, logger *zap.Logger) (*LegacyClient, error)
func (*LegacyClient) CheckInstantAvailability ¶ added in v0.2.0
func (*LegacyClient) GetStreamURL ¶ added in v0.2.0
func (*LegacyClient) TestAPIkey ¶ added in v0.2.0
func (c *LegacyClient) TestAPIkey(ctx context.Context, apiKey string) error
type LegacyClientOptions ¶ added in v0.2.0
type Link ¶ added in v0.2.0
type Link struct { // Download link Link string `json:"link,omitempty"` // File name Filename string `json:"filename,omitempty"` // File size Size int `json:"size,omitempty"` // different format depending of version property Files []interface{} `json:"files,omitempty"` }
Link represents a file in a torrent.
type Magnet ¶ added in v0.2.0
type Magnet struct { // Magnet sent Magnet string `json:"magnet,omitempty"` // Magnet filename, or 'noname' if could not parse it Name string `json:"name,omitempty"` // Magnet id, used to query status ID int `json:"id,omitempty"` // Magnet hash Hash string `json:"hash,omitempty"` // Magnet files size Size int `json:"size,omitempty"` // Whether the magnet is already available Ready bool `json:"ready,omitempty"` }
Magnet represents a magnet that was added to AllDebrid.
type Status ¶ added in v0.2.0
type Status struct { // Magnet id ID int `json:"id,omitempty"` // Magnet filename Filename string `json:"filename,omitempty"` // Magnet filesize Size int `json:"size,omitempty"` // Status in plain English Status string `json:"status,omitempty"` // Status code StatusCode StatusCode `json:"statusCode,omitempty"` // Downloaded data so far Downloaded int `json:"downloaded,omitempty"` // Uploaded data so far Uploaded int `json:"uploaded,omitempty"` // Seeders count Seeders int `json:"seeders,omitempty"` // Download speed DownloadSpeed int `json:"downloadSpeed,omitempty"` // Upload speed UploadSpeed int `json:"uploadSpeed,omitempty"` // Timestamp of the date of the magnet upload UploadDate int `json:"uploadDate,omitempty"` // Timestamp of the date of the magnet completion CompletionDate int `json:"completionDate,omitempty"` // an array of link objects Links []Link `json:"links,omitempty"` // files array format Version int `json:"version,omitempty"` }
Status contains status info about a torrent that was previously uploaded to AllDebrid for a specific user.
type StatusCode ¶ added in v0.2.0
type StatusCode int
StatusCode indicates in which status an added torrent is.
const ( StatusCode_InQueue StatusCode = iota StatusCode_Downloading StatusCode_CompressingMoving StatusCode_Uploading StatusCode_Ready StatusCode_UploadFail StatusCode_InternalErrorOnUnpacking StatusCode_NotDownloadedIn20Min StatusCode_FileTooBig StatusCode_InternalError StatusCode_DownloadTookMoreThan72h StatusCode_DeletedOnTheHosterWebsite )
type Stream ¶ added in v0.2.0
type Stream struct { // Resolution, e.g. `480` if the resolution is 480p. Quality int `json:"quality,omitempty"` // E.g. "mp4" Ext string `json:"ext,omitempty"` // File size in bytes Filesize int `json:"filesize,omitempty"` Name string `json:"name,omitempty"` // Streamable direct link to the file Link string `json:"link,omitempty"` ID string `json:"id,omitempty"` }
Stream is an alternative stream with a different resolution than the original one.
type User ¶ added in v0.2.0
type User struct { // User username Username string `json:"username"` // User email Email string `json:"email"` // true is premium, false if not IsPremium bool `json:"isPremium"` // true is user has active subscription, false if not IsSubscribed bool `json:"isSubscribed"` // true is account is in freedays trial, false if not IsTrial bool `json:"isTrial"` // 0 if user is not premium, or timestamp until user is premium PremiumUntil int `json:"premiumUntil"` // Language used by the user on Alldebrid, eg. 'en', 'fr'. Default to fr Lang string `json:"lang"` // Preferer TLD used by the user, eg. 'fr', 'es'. Default to fr PreferredDomain string `json:"preferedDomain"` // Number of fidelity points FidelityPoints int `json:"fidelityPoints"` // Remaining quotas for the limited hosts (in MB) LimitedHostersQuotas map[string]int `json:"limitedHostersQuotas"` // When in trial mode, remaining global traffic quota available (in MB) RemainingTrialQuota int `json:"remainingTrialQuota,omitempty"` }
User represents an AllDebrid user.