tlapi

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 10 Imported by: 0

README

About

TL API. See: Go reference

Using:

go get github.com/moistari/tlapi

Example:

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/moistari/tlapi"
)

func main() {
	// read PHPSESSID, tluid, and tlpass cookies from browser and build a cookiejar ... hint: use github.com/zellyn/kooky !
	jar := buildJar()
	cl := tlapi.New(tlapi.WithJar(jar))
	res, err := cl.Search(context.Background(), "Fight Club")
	if err != nil {
		log.Fatal(err)
	}
	for i, t := range res.TorrentList {
		fmt.Printf("%02d: %s\n", i, t.Name)
	}
}

Documentation

Index

Constants

View Source
const (
	RangeLast2Weeks  = "[NOW/HOUR-14DAYS TO NOW/HOUR+1HOUR]"
	RangeLastMonth   = "[NOW/HOUR-1MONTH TO NOW/HOUR+1HOUR]"
	RangeLastWeek    = "[NOW/HOUR-7DAYS TO NOW/HOUR+1HOUR]"
	RangeLast24Hours = "[NOW/MINUTE-24HOURS TO NOW/MINUTE+1MINUTE]"
	RangeLast48Hours = "[NOW/MINUTE-48HOURS TO NOW/MINUTE+1MINUTE]"
	RangeLast72Hours = "[NOW/MINUTE-72HOURS TO NOW/MINUTE+1MINUTE]"
	Seeders0to50     = "[0 TO 50]"
	Seeders200Plus   = "[201 TO *]"
	Seeders50to200   = "[51 TO 200]"
	Size0to750MB     = "[0 TO 786432000]"
	Size1_5GBto4_5GB = "[1610612736 TO 4831838208]"
	Size15GBPlus     = "[16106127360 TO *]"
	Size4_5GBto15GB  = "[4831838208 TO 16106127360]"
	Size750MBto1_5GB = "[786432000 TO 1610612736]"
)

Facet values.

View Source
const (
	CategoryMoviesCam               = 8
	CategoryMoviesTSTC              = 9
	CategoryMoviesDVDRipDVDScreener = 11
	CategoryMoviesWebRip            = 37
	CategoryMoviesHDRip             = 43
	CategoryMoviesBluRayRip         = 14
	CategoryMoviesDVDR              = 12
	CategoryMoviesBluRay            = 13
	CategoryMovies4k                = 47
	CategoryMoviesBoxsets           = 15
	CategoryMoviesDocumentaries     = 29

	CategoryTVEpisodes   = 26
	CategoryTVEpisodesHD = 32
	CategoryTVBoxsets    = 27

	CategoryGamesPC             = 17
	CategoryGamesMac            = 42
	CategoryGamesXbox           = 18
	CategoryGamesXbox360        = 19
	CategoryGamesXboxOne        = 40
	CategoryGamesPS2            = 20
	CategoryGamesPS3            = 21
	CategoryGamesPS4            = 39
	CategoryGamesPS5            = 49
	CategoryGamesPSP            = 22
	CategoryGamesWii            = 28
	CategoryGamesNintendoDS     = 30
	CategoryGamesNintendoSwitch = 48

	CategoryAppsPCISO  = 23
	CategoryAppsMac    = 24
	CategoryAppsMobile = 25
	CategoryApps0Day   = 33

	CategoryEducation = 38

	CategoryAnimationAnime    = 34
	CategoryAnimationCartoons = 35

	CategoryBooksEbooks = 45
	CategoryBooksComics = 46

	CategoryMusicAudio  = 31
	CategoryMusicVideos = 16

	CategoryForeignMovies   = 36
	CategoryForeignTVSeries = 44
)

Categories.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Jar       http.CookieJar
	Transport http.RoundTripper
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Client

func (*Client) Do

func (cl *Client) Do(ctx context.Context, req *http.Request, result interface{}) error

func (*Client) Search

func (cl *Client) Search(ctx context.Context, query ...string) (*SearchResponse, error)

Search searches for a query.

func (*Client) Torrent

func (cl *Client) Torrent(ctx context.Context, id int) ([]byte, error)

Torrent retrieves a torrent for the id.

type Facet

type Facet struct {
	Items map[string]Item `json:"items,omitempty"`
	Name  string          `json:"name,omitempty"`
	Title string          `json:"title,omitempty"`
	Type  string          `json:"type,omitempty"`
}

type Item

type Item struct {
	Label string `json:"label,omitempty"`
	Count int    `json:"count,omitempty"`
}

type Option

type Option func(cl *Client)

func WithJar

func WithJar(jar http.CookieJar) Option

func WithTransport

func WithTransport(transport http.RoundTripper) Option

type SearchRequest

type SearchRequest struct {
	Categories []int
	Facets     map[string]string
	Query      []string
	Page       int
}
func Search(query ...string) *SearchRequest

func (*SearchRequest) Do

func (req *SearchRequest) Do(ctx context.Context, cl *Client) (*SearchResponse, error)

func (SearchRequest) WithCategories

func (req SearchRequest) WithCategories(categories ...int) *SearchRequest

func (SearchRequest) WithFacets

func (req SearchRequest) WithFacets(facets ...string) *SearchRequest

func (SearchRequest) WithPage added in v0.1.2

func (req SearchRequest) WithPage(page int) *SearchRequest

type SearchResponse

type SearchResponse struct {
	Facets struct {
		Added   Facet `json:"added,omitempty"`
		Name    Facet `json:"name,omitempty"`
		Seeders Facet `json:"seeders,omitempty"`
		Size    Facet `json:"size,omitempty"`
		Tags    Tags  `json:"tags,omitempty"`
	} `json:"facets,omitempty"`
	Facetswoc      map[string]Tags `json:"facetswoc,omitempty"`
	LastBrowseTime Time            `json:"lastBrowseTime,omitempty"`
	NumFound       int             `json:"numFound,omitempty"`
	OrderBy        string          `json:"orderBy,omitempty"`
	Order          string          `json:"order,omitempty"`
	Page           int             `json:"page,omitempty"`
	PerPage        int             `json:"perPage,omitempty"`
	TorrentList    []Torrent       `json:"torrentList,omitempty"`
	UserTimeZone   string          `json:"userTimeZone,omitempty"`
}

type Tags

type Tags struct {
	Items map[string]int `json:"items,omitempty"`
	Name  string         `json:"name,omitempty"`
	Title string         `json:"title,omitempty"`
	Type  string         `json:"type,omitempty"`
}

type Time

type Time time.Time

func (Time) String

func (t Time) String() string

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(buf []byte) error

type Torrent

type Torrent struct {
	AddedTimestamp     time.Time
	CategoryID         int
	Completed          int
	DownloadMultiplier int
	ID                 int
	Filename           string
	Genres             []string
	IgdbID             string
	ImdbID             string
	Leechers           int
	Name               string
	New                bool
	NumComments        int
	Rating             float64
	Seeders            int
	Size               int64
	Tags               []string
	TvmazeID           string
	Uploader           string
}

func (*Torrent) UnmarshalJSON added in v0.1.3

func (t *Torrent) UnmarshalJSON(buf []byte) error

Jump to

Keyboard shortcuts

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