types

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2016 License: GPL-3.0 Imports: 4 Imported by: 3

Documentation

Overview

Package types contains structs and constants for the xREL package, reflecting the xREL API JSON returns.

Index

Constants

View Source
const (
	TYPE_MOVIE    = "movie"
	TYPE_TV       = "tv"
	TYPE_GAME     = "game"
	TYPE_CONSOLE  = "console"
	TYPE_SOFTWARE = "software"
	TYPE_XXX      = "xxx"

	// 2006-01-02 15:04:05.999999999 -0700 MST
	TIME_FORMAT_COMMENT = "02. Jan 2006, 03:04 pm"
	TIME_FORMAT_RELEASE = "02.01.2006 03:04 pm"
)
View Source
const (
	RELEASE_DATE_TYPE_R5        = "r5"
	RELEASE_DATE_TYPE_DE_CINE   = "de-cine"
	RELEASE_DATE_TYPE_DE_RENTAL = "de-rental"
	RELEASE_DATE_TYPE_DE_RETAIL = "de-retail"
	RELEASE_DATE_TYPE_DE_HD     = "de-hd"
	RELEASE_DATE_TYPE_DE_WEB    = "de-web"
	RELEASE_DATE_TYPE_EN_CINE   = "de-cine"
	RELEASE_DATE_TYPE_EN_RENTAL = "de-rental"
	RELEASE_DATE_TYPE_EN_RETAIL = "de-retail"
	RELEASE_DATE_TYPE_EN_HD     = "de-hd"
	RELEASE_DATE_TYPE_EN_WEB    = "de-web"
)
View Source
const (
	MEDIA_TYPE_IMAGE = "image"
	MEDIA_TYPE_VIDEO = "video"
)
View Source
const (
	P2P_RELEASE_MAIN_LANGUAGE_DE = "german"
	P2P_RELEASE_MAIN_LANGUAGE_EN = "english"
)
View Source
const ERROR_TYPE_API = "api"
View Source
const ERROR_TYPE_CLIENT = "client"
View Source
const ERROR_TYPE_OAUTH = "oauth2"

Variables

View Source
var Config = struct {
	OAuth2Token OAuth2Token

	// 24h caching http://www.xrel.to/wiki/6318/api-release-categories.html
	LastCategoryRequest int64
	Categories          []Category

	// 24h caching http://www.xrel.to/wiki/2996/api-release-filters.html
	LastFilterRequest int64
	Filters           []Filter

	// 24h caching http://www.xrel.to/wiki/3698/api-p2p-categories.html
	LastP2PCategoryRequest int64
	P2PCategories          []P2PCategory

	RateLimitMax       int
	RateLimitRemaining int
	RateLimitResetUnix int64
}{}

Config contains the OAuth2 Token and cached results. Save this somewhere and restore it on every run.

The rate limit information gets set on any request.

Functions

This section is empty.

Types

type AddProofResult

type AddProofResult struct {
	ProofURL   string   `json:"proof_url"`
	ReleaseIDs []string `json:"releases"`
}

type Author

type Author struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type Category

type Category struct {
	Name      string `json:"name"`
	ParentCat string `json:"parent_cat"`
}

type Comment

type Comment struct {
	ID       string `json:"id"`
	TimeUnix int64  `json:"time"`
	Author   Author `json:"author"`
	Text     string `json:"text"`
	LinkURL  string `json:"link_href"`
	Rating   Rating `json:"rating"`
	Votes    Votes  `json:"votes"`
	Edits    Edits  `json:"edits"`
}

func (*Comment) GetTime

func (c *Comment) GetTime() time.Time

type Comments

type Comments struct {
	TotalCount int        `json:"total_count"`
	Pagination Pagination `json:"pagination"`
	List       []Comment  `json:"list"`
}

type Edits

type Edits struct {
	Count    int   `json:"count"`
	LastUnix int64 `json:"last"`
}

func (*Edits) GetLastEditTime

func (edits *Edits) GetLastEditTime() time.Time

type Error

type Error struct {
	Type        string `json:"error_type"`
	Code        string `json:"error"`
	Extra       string
	Description string `json:"error_description"`
}

Error is a struct which implements the normal `error` type, all methods may return this struct. Additional to the `Error()` function this struct contains some variables.

Errors with type `ERROR_TYPE_API` are xREL.to errors (https://www.xrel.to/wiki/6435/api-errors.html), for all other types and error codes see the `NewError` function.

To use this in your code try to cast it: err := xrel.SomeMethod()

if eErr, ok := err.(*types.Error); ok {
	// Is of type types.Error, you can use the variables
} else {
	// Is normal error
}

func NewError

func NewError(errorType, errorCode, errorExtra, errorDesc string) *Error

NewError creates a new error. If you don't specify a description it will be set by the error code.

func (*Error) Error

func (e *Error) Error() string

Error returns the error description.

type ExtInfoExternal

type ExtInfoExternal struct {
	Source  ExtInfoExternalSource `json:"source"`
	LinkURL string                `json:"link_url"`
	Plot    string                `json:"plot"`
}

type ExtInfoExternalSource

type ExtInfoExternalSource struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type ExtInfoMediaItem

type ExtInfoMediaItem struct {
	Type        string `json:"type"`
	Description string `json:"description"`
	TimeUnix    int64  `json:"time"`
	URLFull     string `json:"url_full"` // IsImage()
	URLThumb    string `json:"url_thumb"`
	YoutubeID   string `json:"youtube_id"` // IsVideo()
	VideoURL    string `json:"video_url"`  // IsVideo()
}

func (*ExtInfoMediaItem) GetTime

func (extInfoMediaItem *ExtInfoMediaItem) GetTime() time.Time

type ExtInfoReleaseDate

type ExtInfoReleaseDate struct {
	Type string `json:"type"`
	Date string `json:"date"`
}

type ExtInfoSearchResult

type ExtInfoSearchResult struct {
	Total   int            `json:"total"`
	Results []ShortExtInfo `json:"results"`
}

type ExtendedExtInfo

type ExtendedExtInfo struct {
	ID           string               `json:"id"`
	Type         string               `json:"type"`
	Title        string               `json:"title"`
	LinkURL      string               `json:"link_href"`
	Genre        string               `json:"genre"`
	AltTitle     string               `json:"alt_title"`
	CoverURL     string               `json:"cover_url"`
	URIs         []string             `json:"uris"`
	Rating       float32              `json:"rating"`
	OwnRating    int                  `json:"own_rating"`
	NumRatings   int                  `json:"num_ratings"`
	ReleaseDates []ExtInfoReleaseDate `json:"release_dates"`
	Externals    []ExtInfoExternal    `json:"externals"`
	Releases     []Release            `json:"releases"`
	P2PReleases  []P2PRelease         `json:"p2p_releases"`
}

type FavList

type FavList struct {
	ID             int    `json:"id"`
	Name           string `json:"name"`
	IsPublic       bool   `json:"public"`
	DoNotify       bool   `json:"notify"`
	DoAutoRead     bool   `json:"auto_read"`
	IncludesP2P    bool   `json:"include_p2p"`
	Description    string `json:"description"`
	PasswordHash   string `json:"passwort_hash"`
	EntryCount     int    `json:"entry_count"`
	UnreadReleases int    `json:"unread_releases"`
}

func (*FavList) TestPassword

func (f *FavList) TestPassword(password string) bool

TestPassword tests if a password for a list is correct.

https://www.xrel.to/wiki/1754/api-favs-lists.html

type FavListEntryModificationResult

type FavListEntryModificationResult struct {
	FavList ShortFavList `json:"fav_list"`
	ExtInfo ShortExtInfo `json:"ext_info"`
}

type Filter

type Filter struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type Flags

type Flags struct {
	HasReadNFO bool `json:"read_nfo"`
	IsFixRLS   bool `json:"fix_rls"`
	IsTopRLS   bool `json:"top_rls"`
	IsEnglish  bool `json:"english"`
}

http://www.xrel.to/comments/wiki/1680.html#cpost311058

type Group

type Group struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type OAuth2Token

type OAuth2Token struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int64  `json:"expires_in"`
	Expires      time.Time
	RefreshToken string `json:"refresh_token"`
}

type P2PCategory

type P2PCategory struct {
	ID      string `json:"id"`
	MetaCat string `json:"meta_cat"`
	SubCat  string `json:"sub_cat"`
}

type P2PRelease

type P2PRelease struct {
	ID           string       `json:"id"`
	Dirname      string       `json:"dirname"`
	LinkURL      string       `json:"link_href"`
	MainLanguage string       `json:"main_lang"`
	PubTimeUnix  int64        `json:"pub_time"`
	PostTimeUnix int64        `json:"post_time"`
	SizeInMB     int          `json:"size_mb"`
	Group        Group        `json:"group"`
	NumRatings   int          `json:"num_ratings"`
	VideoRating  float32      `json:"video_rating"`
	AudioRating  float32      `json:"audio_rating"`
	ExtInfo      ShortExtInfo `json:"ext_info"`
	TVSeason     int          `json:"tv_season"`
	TVEpisode    int          `json:"tv_episode"`
	Comments     int          `json:"comments"`
}

func (*P2PRelease) GetPostTime

func (p2pRelease *P2PRelease) GetPostTime() time.Time

func (*P2PRelease) GetPubTime

func (p2pRelease *P2PRelease) GetPubTime() time.Time

type P2PReleases

type P2PReleases struct {
	TotalCount int          `json:"total_count"`
	Pagination Pagination   `json:"pagination"`
	List       []P2PRelease `json:"list"`
}

type Pagination

type Pagination struct {
	CurrentPage int `json:"current_page"`
	PerPage     int `json:"per_page"`
	TotalPages  int `json:"total_pages"`
}

type Rating

type Rating struct {
	Video int `json:"video"`
	Audio int `json:"audio"`
}

type Release

type Release struct {
	ID          string       `json:"id"`
	Dirname     string       `json:"dirname"`
	LinkURL     string       `json:"link_href"`
	TimeUnix    int64        `json:"time"`
	GroupName   string       `json:"group_name"`
	NukeReason  string       `json:"nuke_reason"`
	Size        Size         `json:"size"`
	VideoType   string       `json:"video_type"`
	AudioType   string       `json:"audio_type"`
	NumRatings  int          `json:"num_ratings"`
	VideoRating float32      `json:"video_rating"`
	AudioRating float32      `json:"audio_rating"`
	ExtInfo     ShortExtInfo `json:"ext_info"`
	TVSeason    int          `json:"tv_season"`
	TVEpisode   int          `json:"tv_episode"`
	Comments    int          `json:"comments"`
	Flags       Flags        `json:"flags"`
	ProofURL    string       `json:"proof_url"`
}

func (*Release) GetTime

func (release *Release) GetTime() time.Time

type ReleaseSearchResult

type ReleaseSearchResult struct {
	Total        int          `json:"total"`
	SceneResults []Release    `json:"results"`
	P2PResults   []P2PRelease `json:"p2p_results"`
}

type Releases

type Releases struct {
	TotalCount int        `json:"total_count"`
	Pagination Pagination `json:"pagination"`
	List       []Release  `json:"list"`
}

type ShortExtInfo

type ShortExtInfo struct {
	ID         string   `json:"id"`
	Type       string   `json:"type"`
	Title      string   `json:"title"`
	LinkURL    string   `json:"link_href"`
	Rating     float32  `json:"rating"`
	NumRatings int      `json:"num_ratings"`
	URIs       []string `json:"uris"`
}

type ShortFavList

type ShortFavList struct {
	ID             int    `json:"id"`
	Name           string `json:"string"`
	EntryCount     int    `json:"entry_count"`
	UnreadReleases int    `json:"unread_releases"`
}

type Size

type Size struct {
	Number int    `json:"number"`
	Unit   string `json:"unit"`
}

type UpcomingTitle

type UpcomingTitle struct {
	ID          string                    `json:"id"`
	Type        string                    `json:"type"`
	Title       string                    `json:"title"`
	LinkHref    string                    `json:"link_href"`
	Genre       string                    `json:"genre"`
	AltTitle    string                    `json:"alt_title"`
	CoverURL    string                    `json:"cover_url"`
	Releases    []UpcomingTitleRelease    `json:"releases"`
	P2PReleases []UpcomingTitleP2PRelease `json:"p2p_releases"`
}

type UpcomingTitleP2PRelease

type UpcomingTitleP2PRelease struct {
	ID          string `json:"id"`
	Dirname     string `json:"dirname"`
	LinkURL     string `json:"link_href"`
	PubTimeUnix int64  `json:"pub_time"`
}

func (*UpcomingTitleP2PRelease) GetPubTime

func (upcomingTitleP2PRelease *UpcomingTitleP2PRelease) GetPubTime() time.Time

type UpcomingTitleRelease

type UpcomingTitleRelease struct {
	ID       string `json:"id"`
	Dirname  string `json:"dirname"`
	LinkURL  string `json:"link_href"`
	TimeUnix int64  `json:"time"`
	Flags    Flags  `json:"flags"`
}

func (*UpcomingTitleRelease) GetTime

func (upcomingTitleRelease *UpcomingTitleRelease) GetTime() time.Time

type User

type User struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	Secret         string `json:"secret"`
	Locale         string `json:"locale"`
	AvatarURL      string `json:"avatar_url"`
	AvatarThumbURL string `json:"avatar_thumb_url"`
}

type Votes

type Votes struct {
	Positive int `json:"positive"`
	Negative int `json:"negative"`
}

Jump to

Keyboard shortcuts

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