znab

package
v0.0.0-...-2e152c4 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const TimeFormat = "Mon, 02 Jan 2006 15:04:05 -0700"

rfc822

Variables

View Source
var (
	ErrorIncorrectUserCreds     = Error{Code: 100, Description: "Incorrect user credentials"}
	ErrorAccountSuspended       = Error{Code: 101, Description: "Account suspended"}
	ErrorInsufficientPrivs      = Error{Code: 102, Description: "Insufficient privileges/not authorized"}
	ErrorRegistrationDenied     = Error{Code: 103, Description: "Registration denied"}
	ErrorRegistrationsAreClosed = Error{Code: 104, Description: "Registrations are closed"}
	ErrorEmailAddressTaken      = Error{Code: 105, Description: "Invalid registration (Email Address Taken)"}
	ErrorEmailAddressBadFormat  = Error{Code: 106, Description: "Invalid registration (Email Address Bad Format)"}
	ErrorRegistrationFailed     = Error{Code: 107, Description: "Registration Failed (Data error)"}

	ErrorMissingParameter = func(desc string) error {
		err := Error{Code: 200, Description: "Missing parameter"}
		if desc != "" {
			err.Description += ": " + desc
		}
		return err
	}
	ErrorIncorrectParameter = func(desc string) error {
		err := Error{Code: 201, Description: "Incorrect parameter"}
		if desc != "" {
			err.Description += ": " + desc
		}
		return err
	}
	ErrorNoSuchFunction       = Error{Code: 202, Description: "No such function. (Function not defined in this specification)."}
	ErrorFunctionNotAvailable = Error{Code: 203, Description: "Function not available. (Optional function is not implemented)."}

	ErrorNoSuchItem = Error{Code: 300, Description: "No such item."}

	ErrorRequestLimitReached  = Error{Code: 500, Description: "Request limit reached"}
	ErrorDownloadLimitReached = Error{Code: 501, Description: "Download limit reached"}

	ErrorUnknownError = func(desc string) error {
		err := Error{Code: 900, Description: "Unknown error"}
		if desc != "" {
			err.Description += ": " + desc
		}
		return err
	}

	ErrorAPIDisabled = Error{Code: 910, Description: "API Disabled"}
)

Functions

This section is empty.

Types

type Caps

type Caps struct {
	Server     *CapsServer
	Limits     *CapsLimits
	Searching  *CapsSearching
	Categories []CapsCategory
}

func (Caps) MarshalJSON

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

func (Caps) MarshalXML

func (c Caps) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (Caps) SupportsFunction

func (caps Caps) SupportsFunction(t Function) bool

func (Caps) SupportsParam

func (caps Caps) SupportsParam(t Function, param SearchParam) bool

type CapsCategory

type CapsCategory struct {
	XMLName xml.Name `xml:"category"`
	Category
	Subcat []Category `xml:"subcat"`
}

type CapsLimits

type CapsLimits struct {
	XMLName xml.Name `xml:"limits" json:"-"`
	Max     int      `xml:"max,attr,omitempty" json:"max,omitempty"`
	Default int      `xml:"default,attr,omitempty" json:"default,omitempty"`
}

type CapsSearching

type CapsSearching struct {
	XMLName     xml.Name           `xml:"searching"`
	Search      *CapsSearchingItem `xml:"search,omitempty"`
	TVSearch    *CapsSearchingItem `xml:"tv-search,omitempty"`
	MovieSearch *CapsSearchingItem `xml:"movie-search,omitempty"`
	MusicSearch *CapsSearchingItem `xml:"music-search,omitempty"`
	AudioSearch *CapsSearchingItem `xml:"audio-search,omitempty"`
	BookSearch  *CapsSearchingItem `xml:"book-search,omitempty"`
}

func (CapsSearching) MarshalJSON

func (cs CapsSearching) MarshalJSON() ([]byte, error)

type CapsSearchingItem

type CapsSearchingItem struct {
	Available       CapsSearchingItemAvailable       `xml:"available,attr" json:"available"`
	SupportedParams CapsSearchingItemSupportedParams `xml:"supportedParams,attr" json:"supportedParams,omitempty"`
	SearchEngine    string                           `xml:"searchEngine,attr,omitempty" json:"searchEngine,omitempty"` // raw
	// contains filtered or unexported fields
}

func (*CapsSearchingItem) IsEmpty

func (csi *CapsSearchingItem) IsEmpty() bool

func (*CapsSearchingItem) IsZero

func (csi *CapsSearchingItem) IsZero() bool

func (*CapsSearchingItem) SupportsParam

func (csi *CapsSearchingItem) SupportsParam(param SearchParam) bool

type CapsSearchingItemAvailable

type CapsSearchingItemAvailable bool

func (CapsSearchingItemAvailable) MarshalXMLAttr

func (b CapsSearchingItemAvailable) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (*CapsSearchingItemAvailable) UnmarshalXMLAttr

func (b *CapsSearchingItemAvailable) UnmarshalXMLAttr(attr xml.Attr) error

type CapsSearchingItemSupportedParams

type CapsSearchingItemSupportedParams []SearchParam

func (CapsSearchingItemSupportedParams) MarshalJSON

func (sp CapsSearchingItemSupportedParams) MarshalJSON() ([]byte, error)

func (CapsSearchingItemSupportedParams) MarshalXMLAttr

func (sp CapsSearchingItemSupportedParams) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (*CapsSearchingItemSupportedParams) UnmarshalJSON

func (sp *CapsSearchingItemSupportedParams) UnmarshalJSON(data []byte) error

func (*CapsSearchingItemSupportedParams) UnmarshalXMLAttr

func (sp *CapsSearchingItemSupportedParams) UnmarshalXMLAttr(attr xml.Attr) error

type CapsServer

type CapsServer struct {
	XMLName   xml.Name `xml:"server" json:"-"`
	Version   string   `xml:"version,attr,omitempty" json:"version,omitempty"`
	Title     string   `xml:"title,attr,omitempty" json:"title,omitempty"`
	Strapline string   `xml:"strapline,attr,omitempty" json:"strapline,omitempty"`
	Email     string   `xml:"email,attr,omitempty" json:"email,omitempty"`
	URL       string   `xml:"url,attr,omitempty" json:"url,omitempty"`
	Image     string   `xml:"image,attr,omitempty" json:"image,omitempty"`
}

type Categories

type Categories []Category

func (Categories) Len

func (slice Categories) Len() int

func (Categories) Less

func (slice Categories) Less(i, j int) bool

func (Categories) Swap

func (slice Categories) Swap(i, j int)

type Category

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

func (Category) String

func (c Category) String() string

type Channel

type Channel[Item any] struct {
	XMLName     xml.Name `xml:"channel" json:"-"`
	Title       string   `xml:"title,omitempty" json:"title,omitempty"`
	Description string   `xml:"description,omitempty" json:"description,omitempty"`
	Link        string   `xml:"link,omitempty" json:"link,omitempty"`
	Language    string   `xml:"language,omitempty" json:"language,omitempty"`
	Category    string   `xml:"category,omitempty" json:"category,omitempty"`
	Items       []Item   `xml:"item" json:"items"`
}

type ChannelItem

type ChannelItem struct {
	XMLName xml.Name `xml:"item" json:"-"`

	Category    string               `xml:"category,omitempty" json:"category,omitempty"`
	Description string               `xml:"description,omitempty" json:"description,omitempty"`
	Enclosure   ChannelItemEnclosure `xml:"enclosure,omitempty" json:"-"`
	Files       int                  `xml:"files,omitempty" json:"files,omitempty"`
	GUID        string               `xml:"guid,omitempty" json:"guid,omitempty"`
	Link        string               `xml:"link,omitempty" json:"link,omitempty"`
	PublishDate string               `xml:"pubDate,omitempty" json:"pubDate,omitempty"` // Mon, 02 Jan 2006 15:04:05 -0700
	Size        int64                `xml:"size,omitempty" json:"size,omitempty"`
	Title       string               `xml:"title,omitempty" json:"title,omitempty"`
	Attributes  ChannelItemAttrs     `xml:"-" json:"attr"`
}

func (ChannelItem) GetPublishDate

func (ci ChannelItem) GetPublishDate() time.Time

type ChannelItemAttr

type ChannelItemAttr struct {
	XMLName xml.Name            `json:"-"`
	Name    ChannelItemAttrName `xml:"name,attr" json:"name"`
	Value   string              `xml:"value,attr" json:"value"`
}

type ChannelItemAttrName

type ChannelItemAttrName string
const (
	NewznabAttrNameCategory   ChannelItemAttrName = "category"   // required - Item's category ID
	NewznabAttrNameSize       ChannelItemAttrName = "size"       // required - Size in bytes
	NewznabAttrNameFiles      ChannelItemAttrName = "files"      // Number of files
	NewznabAttrNamePoster     ChannelItemAttrName = "poster"     // NNTP Poster
	NewznabAttrNameGroup      ChannelItemAttrName = "group"      // NNTP Group(s)
	NewznabAttrNamePassword   ChannelItemAttrName = "password"   // 0=no, 1=rar pass, 2=inner archive
	NewznabAttrNameGrabs      ChannelItemAttrName = "grabs"      // Number of times downloaded
	NewznabAttrNameComments   ChannelItemAttrName = "comments"   // Number of comments
	NewznabAttrNameUsenetDate ChannelItemAttrName = "usenetdate" // Date posted to usenet
	NewznabAttrNameInfo       ChannelItemAttrName = "info"       // Info URL
	NewznabAttrNameGUID       ChannelItemAttrName = "guid"       // GUID
	NewznabAttrNameYear       ChannelItemAttrName = "year"       // Release year
	NewznabAttrNameTeam       ChannelItemAttrName = "team"       // Team doing the release
	NewznabAttrNameGenre      ChannelItemAttrName = "genre"      // Genre
	NewznabAttrNameNFO        ChannelItemAttrName = "nfo"        // Contains NFO (1/0)
	NewznabAttrNameSHA1       ChannelItemAttrName = "sha1"       // SHA1 hash
	NewznabAttrNamePrematch   ChannelItemAttrName = "prematch"   // Has valid PreDB match (0/1)
	NewznabAttrNameLanguage   ChannelItemAttrName = "language"   // Content language
	NewznabAttrNameSubs       ChannelItemAttrName = "subs"       // Subtitle languages
	NewznabAttrNameReview     ChannelItemAttrName = "review"     // Review text/description

	NewznabAttrNameIndexerHost ChannelItemAttrName = "indexerhost"
	NewznabAttrNameIndexerName ChannelItemAttrName = "indexername"

	NewznabAttrNameSeason     ChannelItemAttrName = "season"     // Numeric season
	NewznabAttrNameEpisode    ChannelItemAttrName = "episode"    // Numeric episode
	NewznabAttrNameEp         ChannelItemAttrName = "ep"         // Episode (alternative)
	NewznabAttrNameTVDBId     ChannelItemAttrName = "tvdbid"     // TVDB ID
	NewznabAttrNameTVRageId   ChannelItemAttrName = "rageid"     // TVRage ID
	NewznabAttrNameTVRageId2  ChannelItemAttrName = "tvrageid"   // TVRage ID (alternative)
	NewznabAttrNameTVMazeId   ChannelItemAttrName = "tvmazeid"   // TVMaze ID
	NewznabAttrNameTraktId    ChannelItemAttrName = "traktid"    // Trakt.tv ID
	NewznabAttrNameTVTitle    ChannelItemAttrName = "tvtitle"    // TV Show Title
	NewznabAttrNameFirstAired ChannelItemAttrName = "firstaired" // TV Show Air date

	NewznabAttrNameIMDB     ChannelItemAttrName = "imdb"     // IMDB ID (numeric, without "tt" prefix)
	NewznabAttrNameIMDBId   ChannelItemAttrName = "imdbid"   // IMDB ID (alternative)
	NewznabAttrNameTMDBId   ChannelItemAttrName = "tmdbid"   // TMDB ID
	NewznabAttrNameDoubanId ChannelItemAttrName = "doubanid" // Douban ID (Asian content)

	NewznabAttrNameVideo       ChannelItemAttrName = "video"       // Video codec
	NewznabAttrNameAudio       ChannelItemAttrName = "audio"       // Audio codec
	NewznabAttrNameResolution  ChannelItemAttrName = "resolution"  // Video resolution
	NewznabAttrNameCoverURL    ChannelItemAttrName = "coverurl"    // Cover image URL
	NewznabAttrNameBackdropURL ChannelItemAttrName = "backdropurl" // Backdrop/fanart image URL
	NewznabAttrNameBannerURL   ChannelItemAttrName = "bannerurl"   // Banner image URL

	NewznabAttrNameArtist        ChannelItemAttrName = "artist"        // Artist name
	NewznabAttrNameAlbum         ChannelItemAttrName = "album"         // Album name
	NewznabAttrNameLabel         ChannelItemAttrName = "label"         // Record label
	NewznabAttrNameTracks        ChannelItemAttrName = "tracks"        // Number of tracks
	NewznabAttrNameMusicBrainzId ChannelItemAttrName = "musicbrainzid" // MusicBrainz ID

	NewznabAttrNameAuthor      ChannelItemAttrName = "author"      // Author name
	NewznabAttrNameBookTitle   ChannelItemAttrName = "booktitle"   // Book title
	NewznabAttrNamePublisher   ChannelItemAttrName = "publisher"   // Publisher
	NewznabAttrNamePublishDate ChannelItemAttrName = "publishdate" // Publication date

	NewznabAttrNamePlatform ChannelItemAttrName = "platform" // Gaming platform (Xbox360, PS3, etc.)
)
const (
	TorznabAttrNameCategory             ChannelItemAttrName = "category"
	TorznabAttrNameInfoHash             ChannelItemAttrName = "infohash"
	TorznabAttrNameMagnetURL            ChannelItemAttrName = "magneturl"
	TorznabAttrNameIMDB                 ChannelItemAttrName = "imdb"
	TorznabAttrNameIMDBId               ChannelItemAttrName = "imdbid"
	TorznabAttrNameGenre                ChannelItemAttrName = "genre"
	TorznabAttrNameSeeders              ChannelItemAttrName = "seeders"
	TorznabAttrNamePeers                ChannelItemAttrName = "peers"
	TorznabAttrNameLeechers             ChannelItemAttrName = "leechers"
	TorznabAttrNameMinimumRatio         ChannelItemAttrName = "minimumratio"
	TorznabAttrNameMinimumSeedTime      ChannelItemAttrName = "minimumseedtime"
	TorznabAttrNameDownloadVolumeFactor ChannelItemAttrName = "downloadvolumefactor"
	TorznabAttrNameUploadVolumeFactor   ChannelItemAttrName = "uploadvolumefactor"
	TorznabAttrNameCoverURL             ChannelItemAttrName = "coverurl"
	TorznabAttrNameSize                 ChannelItemAttrName = "size"

	TorznabAttrNameIndexerHost ChannelItemAttrName = "indexerhost"
	TorznabAttrNameIndexerName ChannelItemAttrName = "indexername"
)

type ChannelItemAttrs

type ChannelItemAttrs []ChannelItemAttr

func (ChannelItemAttrs) Get

func (ChannelItemAttrs) GetAll

func (attrs ChannelItemAttrs) GetAll(name ChannelItemAttrName) []string

func (ChannelItemAttrs) MarshalJSON

func (attrs ChannelItemAttrs) MarshalJSON() ([]byte, error)

type ChannelItemEnclosure

type ChannelItemEnclosure struct {
	XMLName xml.Name `xml:"enclosure" json:"-"`
	URL     string   `xml:"url,attr,omitempty"`
	Length  int64    `xml:"length,attr,omitempty"`
	Type    string   `xml:"type,attr,omitempty"` // application/x-bittorrent, application/x-nzb
}

func (ChannelItemEnclosure) MarshalJSON

func (e ChannelItemEnclosure) MarshalJSON() ([]byte, error)

type Error

type Error struct {
	XMLName     xml.Name `xml:"error"`
	Code        int      `xml:"code,attr"`
	Description string   `xml:"description,attr"`

	StatusCode int           `xml:"-"`
	RetryAfter time.Duration `xml:"-"`
}

func (Error) Error

func (e Error) Error() string

func (Error) MarshalJSON

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

type Function

type Function string
const (
	FunctionCaps        Function = "caps"
	FunctionSearch      Function = "search"
	FunctionSearchTV    Function = "tvsearch"
	FunctionSearchMovie Function = "movie"
	FunctionSearchMusic Function = "music"
	FunctionSearchBook  Function = "book"
)

type Info

type Info struct {
	ID          string
	Title       string
	Description string
	Link        string
	Language    string
	Category    string
}

type JSONFeed

type JSONFeed[ChannelItem any] struct {
	Attributes struct {
		Version string `json:"version,omitempty"`
	} `json:"@attributes"`
	RSSFeed[ChannelItem]
}

type RSSFeed

type RSSFeed[ChannelItem any] struct {
	XMLName          xml.Name             `xml:"rss" json:"-"`
	AtomNamespace    string               `xml:"xmlns:atom,attr" json:"-"`
	TorznabNamespace string               `xml:"xmlns:torznab,attr" json:"-"`
	Version          string               `xml:"version,attr,omitempty" json:"-"`
	Channel          Channel[ChannelItem] `xml:"channel" json:"channel"`
}

type SearchParam

type SearchParam = string
const (
	SearchParamT        SearchParam = "t"
	SearchParamAPIKey   SearchParam = "apikey"
	SearchParamCat      SearchParam = "cat"
	SearchParamAttrs    SearchParam = "attrs"
	SearchParamExtended SearchParam = "extended"
	SearchParamOffset   SearchParam = "offset"
	SearchParamLimit    SearchParam = "limit"
	SearchParamQ        SearchParam = "q"
	SearchParamEp       SearchParam = "ep"
	SearchParamSeason   SearchParam = "season"
	SearchParamYear     SearchParam = "year"
	SearchParamIMDBId   SearchParam = "imdbid"
	SearchParamTVDBId   SearchParam = "tvdbid"
	SearchParamTVMazeId SearchParam = "tvmazeid"
	SearchParamTraktId  SearchParam = "traktid"
	SearchParamRageId   SearchParam = "rid" // TVRage ID
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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