yts

package module
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: MIT Imports: 17 Imported by: 0

README

yflicks-yts

YTS API client library for the yflicks desktop application

Documentation

Index

Constants

View Source
const (
	DefaultAPIBaseURL = "https://yts.mx/api/v2"
	DefaultSiteURL    = "https://yts.mx"
	DefaultSiteDomain = "yts.mx"
)
View Source
const (
	TimeoutLimitUpper = 5 * time.Minute
	TimeoutLimitLower = 5 * time.Second
)

Variables

View Source
var (
	ErrInvalidClientConfig     = errors.New("invalid_client_config")
	ErrContentRetrievalFailure = errors.New("content_retrieval_failure")
	ErrFilterValidationFailure = errors.New("filter_validation_failure")
)
View Source
var ErrUnexpectedHTTPResponseStatus = errors.New(
	"unexpected_http_response_status",
)

Functions

func DefaultTorrentTrackers added in v0.9.0

func DefaultTorrentTrackers() []string

Types

type BaseResponse

type BaseResponse struct {
	Status        string `json:"status"`
	StatusMessage string `json:"status_message"`
	Meta          `json:"@meta"`
}

type Cast

type Cast struct {
	Name          string `json:"name"`
	CharacterName string `json:"character_name"`
	ImdbCode      string `json:"imdb_code"`
	URLSmallImage string `json:"url_small_image"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func NewClientWithConfig added in v0.9.0

func NewClientWithConfig(config *ClientConfig) *Client

func (*Client) GetHomePageContent added in v0.8.0

func (c *Client) GetHomePageContent() (*HomePageContentResponse, error)

func (*Client) GetHomePageContentWithContext added in v0.9.6

func (c *Client) GetHomePageContentWithContext(ctx context.Context) (
	*HomePageContentResponse, error,
)
func (c *Client) GetMagnetLinks(t TorrentInfoGetter) TorrentMagnets

func (*Client) GetMovieDetails

func (c *Client) GetMovieDetails(movieID int, filters *MovieDetailsFilters) (*MovieDetailsResponse, error)

func (*Client) GetMovieDetailsWithContext added in v0.9.6

func (c *Client) GetMovieDetailsWithContext(ctx context.Context, movieID int, filters *MovieDetailsFilters) (
	*MovieDetailsResponse, error,
)

func (*Client) GetMovieSuggestions

func (c *Client) GetMovieSuggestions(movieID int) (*MovieSuggestionsResponse, error)

func (*Client) GetMovieSuggestionsWithContext added in v0.9.6

func (c *Client) GetMovieSuggestionsWithContext(ctx context.Context, movieID int) (
	*MovieSuggestionsResponse, error,
)

func (*Client) GetTrendingMovies added in v0.8.0

func (c *Client) GetTrendingMovies() (*TrendingMoviesResponse, error)

func (*Client) GetTrendingMoviesWithContext added in v0.9.6

func (c *Client) GetTrendingMoviesWithContext(ctx context.Context) (
	*TrendingMoviesResponse, error,
)

func (*Client) SearchMovies

func (c *Client) SearchMovies(filters *SearchMoviesFilters) (*SearchMoviesResponse, error)

func (*Client) SearchMoviesWithContext added in v0.9.6

func (c *Client) SearchMoviesWithContext(ctx context.Context, filters *SearchMoviesFilters) (
	*SearchMoviesResponse, error,
)

type ClientConfig added in v0.9.0

type ClientConfig struct {
	APIBaseURL      url.URL
	SiteURL         url.URL
	SiteDomain      string
	TorrentTrackers []string
	RequestTimeout  time.Duration
	Debug           bool
}

func DefaultClientConfig added in v0.9.0

func DefaultClientConfig() ClientConfig

type Genre added in v0.8.2

type Genre string
const (
	GenreAll         Genre = "all"
	GenreAction      Genre = "Action"
	GenreAdventure   Genre = "Adventure"
	GenreAnimation   Genre = "Animation"
	GenreBiography   Genre = "Biography"
	GenreComedy      Genre = "Comedy"
	GenreCrime       Genre = "Crime"
	GenreDocumentary Genre = "Documentary"
	GenreDrama       Genre = "Drama"
	GenreFamily      Genre = "Family"
	GenreFantasy     Genre = "Fantasy"
	GenreFilmNoir    Genre = "Film-Noir"
	GenreGameShow    Genre = "Game-Show"
	GenreHistory     Genre = "History"
	GenreHorror      Genre = "Horror"
	GenreMusic       Genre = "Music"
	GenreMusical     Genre = "Musical"
	GenreMystery     Genre = "Mystery"
	GenreNews        Genre = "News"
	GenreRealityTV   Genre = "Reality-TV"
	GenreRomance     Genre = "Romance"
	GenreSciFi       Genre = "Sci-Fi"
	GenreSport       Genre = "Sport"
	GenreTalkShow    Genre = "Talk-show"
	GenreThriller    Genre = "Thriller"
	GenreWar         Genre = "War"
	GenreWestern     Genre = "Western"
)

type HomePageContentData added in v0.8.0

type HomePageContentData struct {
	Popular  []SiteMovie
	Latest   []SiteMovie
	Upcoming []SiteUpcomingMovie
}

type HomePageContentResponse added in v0.8.0

type HomePageContentResponse struct {
	Data HomePageContentData `json:"data"`
}

type Meta

type Meta struct {
	ServerTime     int    `json:"server_time"`
	ServerTimezone string `json:"server_timezone"`
	APIVersion     int    `json:"api_version"`
	ExecutionTime  string `json:"execution_time"`
}

type Movie

type Movie struct {
	MoviePartial
	Summary  string `json:"summary"`
	Synopsis string `json:"synopsis"`
	State    string `json:"state"`
}

type MovieDetails

type MovieDetails struct {
	MoviePartial
	LikeCount              int    `json:"like_count"`
	DescriptionIntro       string `json:"description_intro"`
	MediumScreenshotImage1 string `json:"medium_screenshot_image1"`
	MediumScreenshotImage2 string `json:"medium_screenshot_image2"`
	MediumScreenshotImage3 string `json:"medium_screenshot_image3"`
	LargeScreenshotImage1  string `json:"large_screenshot_image1"`
	LargeScreenshotImage2  string `json:"large_screenshot_image2"`
	LargeScreenshotImage3  string `json:"large_screenshot_image3"`
	Cast                   []Cast `json:"cast"`
}

type MovieDetailsData

type MovieDetailsData struct {
	Movie MovieDetails `json:"movie"`
}

type MovieDetailsFilters

type MovieDetailsFilters struct {
	WithImages bool `json:"with_images"`
	WithCast   bool `json:"with_cast"`
}

func DefaultMovieDetailsFilters

func DefaultMovieDetailsFilters() *MovieDetailsFilters

type MovieDetailsResponse

type MovieDetailsResponse struct {
	BaseResponse
	Data MovieDetailsData `json:"data"`
}

type MoviePartial

type MoviePartial struct {
	ID                      int       `json:"id"`
	URL                     string    `json:"url"`
	ImdbCode                string    `json:"imdb_code"`
	Title                   string    `json:"title"`
	TitleEnglish            string    `json:"title_english"`
	TitleLong               string    `json:"title_long"`
	Slug                    string    `json:"slug"`
	Year                    int       `json:"year"`
	Rating                  float64   `json:"rating"`
	Runtime                 int       `json:"runtime"`
	Genres                  []Genre   `json:"genres"`
	DescriptionFull         string    `json:"description_full"`
	YtTrailerCode           string    `json:"yt_trailer_code"`
	Language                string    `json:"language"`
	MpaRating               string    `json:"mpa_rating"`
	BackgroundImage         string    `json:"background_image"`
	BackgroundImageOriginal string    `json:"background_image_original"`
	SmallCoverImage         string    `json:"small_cover_image"`
	MediumCoverImage        string    `json:"medium_cover_image"`
	LargeCoverImage         string    `json:"large_cover_image"`
	Torrents                []Torrent `json:"torrents"`
	DateUploaded            string    `json:"date_uploaded"`
	DateUploadedUnix        int       `json:"date_uploaded_unix"`
}

func (*MoviePartial) GetTorrentInfo added in v0.9.0

func (mp *MoviePartial) GetTorrentInfo() *TorrentInfo

type MovieSuggestionsData

type MovieSuggestionsData struct {
	MovieCount int     `json:"movie_count"`
	Movies     []Movie `json:"movies"`
}

type MovieSuggestionsResponse

type MovieSuggestionsResponse struct {
	BaseResponse
	Data MovieSuggestionsData `json:"data"`
}

type OrderBy added in v0.8.2

type OrderBy string
const (
	OrderByAsc  OrderBy = "asc"
	OrderByDesc OrderBy = "desc"
)

type Quality added in v0.8.2

type Quality string
const (
	QualityAll       Quality = "all"
	Quality480p      Quality = "480p"
	Quality720p      Quality = "720p"
	Quality1080p     Quality = "1080p"
	Quality1080pX265 Quality = "1080p.x265"
	Quality2160p     Quality = "2160p"
	Quality3D        Quality = "3D"
)

type SearchMoviesData

type SearchMoviesData struct {
	MovieCount int     `json:"movie_count"`
	Limit      int     `json:"limit"`
	PageNumber int     `json:"page_number"`
	Movies     []Movie `json:"movies"`
}

type SearchMoviesFilters

type SearchMoviesFilters struct {
	Limit         int     `json:"limit"`
	Page          int     `json:"page"`
	Quality       Quality `json:"quality"`
	MinimumRating int     `json:"minimum_rating"`
	QueryTerm     string  `json:"query_term"`
	Genre         Genre   `json:"genre"`
	SortBy        SortBy  `json:"sort_by"`
	OrderBy       OrderBy `json:"order_by"`
	WithRTRatings bool    `json:"with_rt_ratings"`
}

func DefaultSearchMoviesFilter

func DefaultSearchMoviesFilter(query string) *SearchMoviesFilters

type SearchMoviesResponse

type SearchMoviesResponse struct {
	BaseResponse
	Data SearchMoviesData `json:"data"`
}

type SiteMovie added in v0.9.0

type SiteMovie struct {
	SiteMovieBase
	Rating string `json:"rating"`
}

type SiteMovieBase added in v0.9.0

type SiteMovieBase struct {
	Title  string  `json:"title"`
	Year   int     `json:"year"`
	Link   string  `json:"link"`
	Image  string  `json:"image"`
	Genres []Genre `json:"genres"`
}

type SiteUpcomingMovie added in v0.9.0

type SiteUpcomingMovie struct {
	SiteMovieBase
	Progress int     `json:"progress"`
	Quality  Quality `json:"quality"`
}

type SortBy added in v0.8.2

type SortBy string
const (
	SortByTitle         SortBy = "title"
	SortByYear          SortBy = "year"
	SortByRating        SortBy = "rating"
	SortByPeers         SortBy = "peers"
	SortBySeeds         SortBy = "seeds"
	SortByDownloadCount SortBy = "download_count"
	SortByLikeCount     SortBy = "like_count"
	SortByDateAdded     SortBy = "date_added"
)

type Torrent

type Torrent struct {
	URL              string  `json:"url"`
	Hash             string  `json:"hash"`
	Quality          Quality `json:"quality"`
	Type             string  `json:"type"`
	IsRepack         string  `json:"is_repack"`
	VideoCodec       string  `json:"video_codec"`
	BitDepth         string  `json:"bit_depth"`
	AudioChannels    string  `json:"audio_channels"`
	Seeds            int     `json:"seeds"`
	Peers            int     `json:"peers"`
	Size             string  `json:"size"`
	SizeBytes        int     `json:"size_bytes"`
	DateUploaded     string  `json:"date_uploaded"`
	DateUploadedUnix int     `json:"date_uploaded_unix"`
}

type TorrentInfo added in v0.9.0

type TorrentInfo struct {
	MovieTitle string
	Torrents   []Torrent
}

type TorrentInfoGetter added in v0.9.0

type TorrentInfoGetter interface {
	GetTorrentInfo() *TorrentInfo
}

type TorrentMagnets added in v0.9.1

type TorrentMagnets map[Quality]string

type TrendingMoviesData added in v0.8.0

type TrendingMoviesData struct {
	Movies []SiteMovie `json:"movies"`
}

type TrendingMoviesResponse added in v0.8.0

type TrendingMoviesResponse struct {
	Data TrendingMoviesData `json:"data"`
}

Jump to

Keyboard shortcuts

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