torznab

package
v0.8.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttrInfoHash  = "infohash"
	AttrMagnetUrl = "magneturl"
	// AttrCategory is the Category ID
	AttrCategory    = "category"
	AttrSize        = "size"
	AttrPublishDate = "publishdate"
	AttrSeeders     = "seeders"
	AttrPeers       = "peers"
	// AttrFiles is the number of files in the torrent
	AttrFiles   = "files"
	AttrYear    = "year"
	AttrSeason  = "season"
	AttrEpisode = "episode"
	// AttrVideo is the video codec
	AttrVideo      = "video"
	AttrResolution = "resolution"
	AttrTeam       = "team"
	AttrImdb       = "imdb"
)
View Source
const (
	FunctionCaps   = "caps"
	FunctionSearch = "search"
	FunctionMovie  = "movie"
	FunctionTv     = "tvsearch"
	FunctionMusic  = "music"
	FunctionBook   = "book"
)
View Source
const (
	ParamType    = "t"
	ParamQuery   = "q"
	ParamCat     = "cat"
	ParamImdbId  = "imdbid"
	ParamTmdbId  = "tmdbid"
	ParamSeason  = "season"
	ParamEpisode = "ep"
	ParamLimit   = "limit"
	ParamOffset  = "offset"
)
View Source
const RssDateDefaultFormat = "Mon, 02 Jan 2006 15:04:05 -0700"

Variables

View Source
var (
	CategoryMovies         = categoriesMap[2000]
	CategoryMoviesSD       = categoriesMap[2030]
	CategoryMoviesHD       = categoriesMap[2040]
	CategoryMoviesUHD      = categoriesMap[2045]
	CategoryMovies3D       = categoriesMap[2060]
	CategoryAudio          = categoriesMap[3000]
	CategoryAudioAudiobook = categoriesMap[3030]
	CategoryPC             = categoriesMap[4000]
	CategoryPCGames        = categoriesMap[4050]
	CategoryTV             = categoriesMap[5000]
	CategoryTVSD           = categoriesMap[5030]
	CategoryTVHD           = categoriesMap[5040]
	CategoryTVUHD          = categoriesMap[5045]
	CategoryXXX            = categoriesMap[6000]
	CategoryXXXOther       = categoriesMap[6070]
	CategoryBooks          = categoriesMap[7000]
	CategoryBooksEBook     = categoriesMap[7020]
	CategoryBooksComics    = categoriesMap[7030]
	CategoryOther          = categoriesMap[8000]
)

Functions

This section is empty.

Types

type Caps

type Caps struct {
	XMLName    xml.Name       `xml:"caps"`
	Server     CapsServer     `xml:"server"`
	Limits     CapsLimits     `xml:"limits"`
	Searching  CapsSearching  `xml:"searching"`
	Categories CapsCategories `xml:"categories"`
	Tags       string         `xml:"tags"`
}

func (Caps) Xml

func (c Caps) Xml() ([]byte, error)

type CapsCategories

type CapsCategories struct {
	Categories []Category `xml:"category"`
}

type CapsLimits

type CapsLimits struct {
	Max     uint `xml:"max,attr,omitempty"`
	Default uint `xml:"default,attr,omitempty"`
}

type CapsSearch

type CapsSearch struct {
	Available       string `xml:"available,attr"`
	SupportedParams string `xml:"supportedParams,attr,omitempty"`
}

type CapsSearching

type CapsSearching struct {
	Search      CapsSearch `xml:"search,omitempty"`
	TvSearch    CapsSearch `xml:"tv-search,omitempty"`
	MovieSearch CapsSearch `xml:"movie-search,omitempty"`
	MusicSearch CapsSearch `xml:"music-search,omitempty"`
	AudioSearch CapsSearch `xml:"audio-search,omitempty"`
	BookSearch  CapsSearch `xml:"book-search,omitempty"`
}

type CapsServer

type CapsServer struct {
	Title string `xml:"title,attr"`
}

type Category

type Category struct {
	ID     int           `xml:"id,attr"`
	Name   string        `xml:"name,attr"`
	Subcat []Subcategory `xml:"subcat"`
}

func (Category) Has

func (c Category) Has(id int) bool

Has returns true if the category has the given id or if any of its subcategories have the given id.

type Client

type Client interface {
	Caps(context.Context) (Caps, error)
	Search(context.Context, SearchRequest) (SearchResult, error)
}

type Error

type Error struct {
	XMLName xml.Name `xml:"error"`

	// Code the Error code.
	//
	// From https://torznab.github.io/spec-1.3-draft/external/newznab/api.html#newznab-error-codes:
	//
	// 100 Incorrect user credentials
	// 101 Account suspended
	// 102 Insufficient privileges/not authorized
	// 103 Registration denied
	// 104 Registrations are closed
	// 105 Invalid registration (Email Address Taken)
	// 106 Invalid registration (Email Address Bad Format)
	// 107 Registration Failed (Data error)
	// 200 Missing parameter
	// 201 Incorrect parameter
	// 202 No such function. (Function not defined in this specification).
	// 203 Function not available. (Optional function is not implemented).
	// 300 No such item.
	// 300 Item already exists.
	// 900 Unknown error
	// 910 API Disabled
	Code        int    `xml:"error,attr"`
	Description string `xml:"description,attr"`
}

Error represents an error that should be encoded to an XML response according to the Torznab specification.

func (Error) Error

func (e Error) Error() string

func (Error) Xml

func (e Error) Xml() ([]byte, error)

type RssDate

type RssDate time.Time

func (RssDate) MarshalXML

func (r RssDate) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (RssDate) String

func (r RssDate) String() string

func (*RssDate) UnmarshalXML

func (r *RssDate) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type SearchRequest

type SearchRequest struct {
	Query    string
	Type     string
	Cats     []int
	ImdbId   model.NullString
	TmdbId   model.NullString
	Season   model.NullInt
	Episode  model.NullInt
	Attrs    []string
	Extended bool
	Limit    model.NullUint
	Offset   model.NullUint
}

type SearchResult

type SearchResult struct {
	XMLName    xml.Name            `xml:"rss"`
	RssVersion rssVersion          `xml:"version,attr"`
	AtomNs     customNs            `xml:"xmlns:atom,attr"`
	TorznabNs  customNs            `xml:"xmlns:torznab,attr"`
	Channel    SearchResultChannel `xml:"channel"`
}

func (SearchResult) Xml

func (r SearchResult) Xml() ([]byte, error)

type SearchResultChannel

type SearchResultChannel struct {
	Title         string               `xml:"title,omitempty"`
	Link          string               `xml:"link,omitempty"`
	Description   string               `xml:"description,omitempty"`
	Language      string               `xml:"language,omitempty"`
	PubDate       RssDate              `xml:"pubDate,omitempty"`
	LastBuildDate RssDate              `xml:"lastBuildDate,omitempty"`
	Docs          string               `xml:"docs,omitempty"`
	Generator     string               `xml:"generator,omitempty"`
	Response      SearchResultResponse `xml:"http://www.newznab.com/DTD/2010/feeds/attributes/ response"`
	Items         []SearchResultItem   `xml:"item"`
}

type SearchResultItem

type SearchResultItem struct {
	Title        string                        `xml:"title"`
	GUID         string                        `xml:"guid,omitempty"`
	PubDate      RssDate                       `xml:"pubDate,omitempty"`
	Category     string                        `xml:"category,omitempty"`
	Link         string                        `xml:"link,omitempty"`
	Size         uint64                        `xml:"size"`
	Description  string                        `xml:"description,omitempty"`
	Comments     string                        `xml:"comments,omitempty"`
	Enclosure    SearchResultItemEnclosure     `xml:"enclosure"`
	TorznabAttrs []SearchResultItemTorznabAttr `xml:"torznab:attr"`
}

type SearchResultItemEnclosure

type SearchResultItemEnclosure struct {
	URL    string `xml:"url,attr"`
	Length string `xml:"length,attr"`
	Type   string `xml:"type,attr"`
}

type SearchResultItemTorznabAttr

type SearchResultItemTorznabAttr struct {
	AttrName  string `xml:"name,attr"`
	AttrValue string `xml:"value,attr"`
}

type SearchResultResponse

type SearchResultResponse struct {
	Offset uint `xml:"offset,attr,omitempty"`
	Total  uint `xml:"total,attr,omitempty"`
}

type Subcategory

type Subcategory struct {
	ID   int    `xml:"id,attr"`
	Name string `xml:"name,attr"`
}

type Xmler

type Xmler interface {
	Xml() ([]byte, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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