jackett

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

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

Go to latest
Published: Jun 30, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

README

go-jackett

Go Jackett client.

Get started

package main

import (
	"context"

	"github.com/SkYNewZ/go-jackett"
)

func main() {
	// Read JACKETT_API_URL and JACKETT_API_KEY by default
	client := jackett.New(nil)
	results, err := client.Fetch(context.Background(), jackett.WithQuery("foo"))
	if err != nil {
		panic(err)
	}

	_ = results // use results
}

Trackers

Available trackers are statically types using cmd/jackett-sync as code generator from https://github.com/Jackett/Jackett/tree/master/src/Jackett.Common/Definitions. You can see the output at trackers/trackers.go.

Documentation

Overview

Example
// Read JACKETT_API_URL and JACKETT_API_KEY by default
client := jackett.New(nil)
results, err := client.Fetch(context.Background(), jackett.WithQuery("foo"))
if err != nil {
	panic(err)
}

_ = results // use results
Output:

Example (DisableSSL)
httpClient := &http.Client{Timeout: time.Minute}
transport := &http.Transport{
	TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
httpClient.Transport = transport

client := jackett.New(&jackett.Config{
	APIUrl:     "https://",
	APIKey:     "foo",
	HTTPClient: httpClient,
})
results, err := client.Fetch(context.Background(), jackett.WithQuery("foo"))
if err != nil {
	panic(err)
}

_ = results // use results
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Fetch make a query to Jackett and returns found results.
	// categoryID must match an existent category ID from Jackett. You can check them on your Jackett instance's indexers configuration.
	// You can specify multiples categories.
	// Custom indexer can be specified. Default will be "all".
	Fetch(ctx context.Context, options ...Option) (*Response, error)
}

Client interface describes wrapped Jackett client.

func New

func New(config *Config) Client

New creates a new Jackett client.

type Config

type Config struct {
	APIUrl     string
	APIKey     string
	HTTPClient *http.Client
}

Config describes available config for Jackett.

type Indexer

type Indexer struct {
	ID      string `json:"ID"`
	Name    string `json:"Name"`
	Status  int    `json:"Status"`
	Results int    `json:"Results"`
	Error   string `json:"Error"`
}

Indexer configured on Jackett.

type Option

type Option func(values *url.Values)

Option describes a query option.

func WithCategory

func WithCategory(category ...uint) Option

WithCategory specify category to filter results with.

func WithQuery

func WithQuery(query string) Option

WithQuery specify the query.

func WithTracker

func WithTracker(tracker ...trackers.Tracker) Option

WithTracker specify tracker to filter results with.

type Response

type Response struct {
	Results  []Result  `json:"Results"`
	Indexers []Indexer `json:"Indexers"`
}

Response is a Jackett search response.

type Result

type Result struct {
	FirstSeen            string      `json:"FirstSeen"`
	Tracker              string      `json:"Tracker"`
	TrackerID            string      `json:"TrackerId"`
	TrackerType          string      `json:"TrackerType"`
	CategoryDesc         string      `json:"CategoryDesc"`
	BlackholeLink        string      `json:"BlackholeLink"`
	Title                string      `json:"Title"`
	GUID                 string      `json:"Guid"`
	Link                 string      `json:"Link"`
	Details              string      `json:"Details"`
	PublishDate          time.Time   `json:"PublishDate"`
	Category             []int       `json:"Category"`
	Size                 int64       `json:"Size"`
	Files                interface{} `json:"Files"`
	Grabs                int         `json:"Grabs"`
	Description          string      `json:"Description"`
	RageID               interface{} `json:"RageID"`
	TVDBID               interface{} `json:"TVDBId"`
	Imdb                 interface{} `json:"Imdb"`
	TMDb                 interface{} `json:"TMDb"`
	DoubanID             interface{} `json:"DoubanId"`
	Author               string      `json:"Author"`
	BookTitle            string      `json:"BookTitle"`
	Seeders              int         `json:"Seeders"`
	Peers                int         `json:"Peers"`
	Poster               interface{} `json:"Poster"`
	InfoHash             interface{} `json:"InfoHash"`
	MagnetURI            interface{} `json:"MagnetUri"`
	MinimumRatio         interface{} `json:"MinimumRatio"`
	MinimumSeedTime      interface{} `json:"MinimumSeedTime"`
	DownloadVolumeFactor float64     `json:"DownloadVolumeFactor"`
	UploadVolumeFactor   float64     `json:"UploadVolumeFactor"`
	Gain                 float64     `json:"Gain"`
}

Result is a search result.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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