debrid

package module
v0.0.0-...-b4ce59b Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: AGPL-3.0 Imports: 2 Imported by: 0

README

go-debrid

Go Reference

Go library for the public APIs of debrid services like RealDebrid, AllDebrid and Premiumize

Features

  • Get user account info
  • Get instant availability (cache) info for a link / torrent
  • Add a link / torrent to a debrid service's downloads
  • Get status info about a link / torrent that the debrid service is downloading / has downloaded
  • Get the direct download link for a link / torrent after the debrid service has downloaded it
  • Delete the torrent that the debrid service is downloading / has downloaded

Usage

The library consists of a root-level package which contains a cache interface and example cache implementation, as well as subpackages for the specific debrid services. Each service-specific subpackage contains both a legacy client (the client from v0.1.0), and a low level client whose methods match the public API endpoints. In the future a common client will be added that has a generic interface and is backed by service-specific clients.

Godoc:

Example
package main

import (
    "context"
    "fmt"

    "github.com/deflix-tv/go-debrid/realdebrid"
)

func main() {
    // Create new client
    auth := realdebrid.Auth{KeyOrToken: "123"}
    rd := realdebrid.NewClient(realdebrid.DefaultClientOpts, auth, nil)

    // We're using some info hashes of "Night of the Living Dead" from 1968, which is in the public domain
    infoHashes := []string{
        "50B7DAFB7137CBECF045F78E8EFBE4AC1A90D139",
        "11EA02584FA6351956F35671962AB46354D99060",
    }
    availabilities, _ := rd.GetInstantAvailability(context.Background(), infoHashes...)

    // Iterate through the available torrents and print their details
    for hash, availability := range availabilities {
        fmt.Printf("Hash: %v\nAvailability: %+v\n", hash, availability)
    }
}

For more detailed examples see examples.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Set(key string) error
	Get(key string) (time.Time, bool, error)
}

Cache is the interface that the debrid clients uses for caching a user's API token validity and the "instant availability" of a torrent (via info_hash). A package user must pass an implementation of this interface. Usually you create a simple wrapper around an existing cache package. An example implementation is the InMemoryCache in this package.

type InMemoryCache

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

InMemoryCache is an example implementation of the Cache interface. It doesn't persist its data, so it's not suited for production use of the debrid packages.

func NewInMemoryCache

func NewInMemoryCache() *InMemoryCache

NewInMemoryCache creates a new InMemoryCache.

func (*InMemoryCache) Get

func (c *InMemoryCache) Get(key string) (time.Time, bool, error)

Get returns the time the API token / "instant availability" was cached. The boolean return value signals if the value was found in the cache.

func (*InMemoryCache) Set

func (c *InMemoryCache) Set(key string) error

Set caches the validity of a user's API token or the "instant availability" for a torrent (via info_hash). There's no need to pass a boolean or so - if a value gets cached it means the token is valid / the torrent is "instantly available".

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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