premiumize

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClientOpts = ClientOptions{
	BaseURL: "https://www.premiumize.me/api",
	Timeout: 5 * time.Second,
}

DefaultClientOpts are ClientOptions with reasonable default values.

View Source
var DefaultLegacyClientOpts = LegacyClientOptions{
	BaseURL:  "https://www.premiumize.me/api",
	Timeout:  5 * time.Second,
	CacheAge: 24 * time.Hour,
}

Functions

This section is empty.

Types

type AccountInfo added in v0.2.0

type AccountInfo struct {
	CustomerID   string  `json:"customer_id,omitempty"`
	PremiumUntil int     `json:"premium_until,omitempty"`
	LimitUsed    float64 `json:"limit_used,omitempty"`
	SpaceUsed    float64 `json:"space_used,omitempty"`
}

AccountInfo contains info about a user account.

type Auth added in v0.2.0

type Auth struct {
	// Long lasting API key or expiring OAuth2 access token
	KeyOrToken string
	// Flag for indicating whether KeyOrToken is a key (false) or token (true).
	OAuth2 bool
	// The user's original IP. Only required if ClientOptions.ForwardOriginIP is true.
	IP string
}

Auth carries authentication/authorization info for Premiumize.

type CachedFile added in v0.2.0

type CachedFile struct {
	Transcoded bool
	Filename   string
	Filesize   string
}

CachedFile represents a file that's available in Premiumize's cache.

type Client

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

Client represents a Premiumize client.

func NewClient

func NewClient(opts ClientOptions, auth Auth, logger *zap.Logger) *Client

NewClient returns a new Premiumize client. The logger param can be nil.

func (*Client) CheckCache added in v0.2.0

func (c *Client) CheckCache(ctx context.Context, items ...string) (map[string]CachedFile, error)

CheckCache checks if files are already in Premiumize's cache. An item can be any link that Premiumize supports: Containers, direct links, magnet URLs, torrent info hashes. The returned map contains only entries for cached files and uses the item as key.

func (*Client) CreateDDL added in v0.2.0

func (c *Client) CreateDDL(ctx context.Context, source string) ([]Download, error)

CreateDDL creates direct download links. The source can be an HTTP(S) link to a supported container file, website or magnet link. The creation will only work if the file is cached on Premiumize or if a transfer for the file has been created before and the transfer finished downloading (to Premiumize). If the source contains multiple files, each file is an element in the slice of Download objects.

func (*Client) CreateTransfer added in v0.2.0

func (c *Client) CreateTransfer(ctx context.Context, source string) (CreatedTransfer, error)

CreateTransfer creates a transfer. The source can be an HTTP(S) link to a supported container file, website or magnet link. Transfers that are created this way will appear in the transfer list.

func (*Client) GetAccountInfo added in v0.2.0

func (c *Client) GetAccountInfo(ctx context.Context) (AccountInfo, error)

GetAccountInfo fetches and returns info about the user's account.

func (*Client) ListTransfers added in v0.2.0

func (c *Client) ListTransfers(ctx context.Context) ([]Transfer, error)

ListTransfers fetches and returns all transfers that were previously added to Premiumize for a specific user. This doesn't include downloads that were created with CreateDDL without having been added via CreateTransfer.

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 Premiumize 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
	// When setting this to true, the user's original IP address is read from Auth.IP and forwarded to Premiumize when creating a direct download links.
	// Only required if the library is used in an app on a machine
	// whose outgoing IP is different from the machine that's going to request the cached file/stream URL.
	ForwardOriginIP bool
}

ClientOptions are options for the client.

type CreatedTransfer added in v0.2.0

type CreatedTransfer struct {
	Type string `json:"type,omitempty"`
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

CreatedTransfer represents a transfer that has just been added to Premiumize.

type Download added in v0.2.0

type Download struct {
	Path            string `json:"path,omitempty"`
	Size            string `json:"size,omitempty"`
	Link            string `json:"link,omitempty"`
	StreamLink      string `json:"stream_link,omitempty"`
	TranscodeStatus string `json:"transcode_status,omitempty"`
}

Download represents a direct download. If a transfer was created by adding a torrent, a Download is a file in that torrent.

func SelectLargestFile added in v0.2.0

func SelectLargestFile(downloads []Download) (Download, error)

SelectLargestFile returns the largest file in a slice of Download objects.

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 (c *LegacyClient) CheckInstantAvailability(ctx context.Context, auth Auth, infoHashes ...string) []string

func (*LegacyClient) GetStreamURL added in v0.2.0

func (c *LegacyClient) GetStreamURL(ctx context.Context, magnetURL string, auth Auth) (string, error)

func (*LegacyClient) TestAPIkey added in v0.2.0

func (c *LegacyClient) TestAPIkey(ctx context.Context, auth Auth) error

type LegacyClientOptions added in v0.2.0

type LegacyClientOptions struct {
	BaseURL      string
	Timeout      time.Duration
	CacheAge     time.Duration
	ExtraHeaders []string
	// When setting this to true, the user's original IP address is read from Auth.IP and forwarded to Premiumize when creating a direct download links.
	// Only required if the library is used in an app on a machine
	// whose outgoing IP is different from the machine that's going to request the cached file/stream URL.
	ForwardOriginIP bool
}

type Transfer added in v0.2.0

type Transfer struct {
	ID string `json:"id,omitempty"`
	// Name of the torrent if the transfer was created by adding a torrent
	Name    string `json:"name,omitempty"`
	Message string `json:"message,omitempty"`
	// "waiting", "finished" etc.
	Status string `json:"status,omitempty"`
	// Download progress. Can be 0 for cached files that don't have to be downloaded.
	Progress float64 `json:"progress,omitempty"`
	// When the transfer was created by adding a torrent via magnet URL, then this is the magnet URL
	Src      string `json:"src,omitempty"`
	FolderID string `json:"folder_id,omitempty"`
	FileID   string `json:"file_id,omitempty"`
}

Transfer represents a transfer, like a torrent that has been added to Premiumize for a specific user.

Jump to

Keyboard shortcuts

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