rest

package module
v0.0.0-...-81a0f4d Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Version = "0.0.1"
)

Variables

This section is empty.

Functions

func AllocateBool

func AllocateBool(v bool) *bool

Allocates a new bool value to store v and returns a pointer to it.

func AllocateFloat32

func AllocateFloat32(v float32) *float32

Allocates a new float32 value to store v and returns a pointer to it.

func AllocateInt

func AllocateInt(v int) *int

Allocates a new int value to store v and returns a pointer to it.

func AllocateString

func AllocateString(v string) *string

Allocates a new string value to store v and returns a pointer to it.

func AllocateTime

func AllocateTime(v string) *time.Time

Allocates a new time.Time value to store v and returns a pointer to it.

func CheckResponse

func CheckResponse(res *http.Response) error

Types

type APIKeyError

type APIKeyError ResponseError

func (*APIKeyError) Error

func (e *APIKeyError) Error() string

type AuthService

type AuthService service

func (*AuthService) Login

func (s *AuthService) Login(ctx context.Context, c *Credentials) (*Login, *Response, error)

Creates a token to authenticate a user.

OpenSubtitles Reference

func (*AuthService) Logout

func (s *AuthService) Logout(ctx context.Context) (*Response, error)

Destroys a token to end a session.

OpenSubtitles Reference

type AuthTokenError

type AuthTokenError ResponseError

func (*AuthTokenError) Error

func (e *AuthTokenError) Error() string

type Client

type Client struct {
	APIKey    string
	UserAgent string
	BaseURL   *url.URL

	Auth      *AuthService
	Features  *FeaturesService
	Formats   *FormatsService
	Languages *LanguagesService
	Subtitles *SubtitlesService
	Users     *UsersService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(client *http.Client) *Client

func (*Client) BareDo

func (c *Client) BareDo(ctx context.Context, req *http.Request) (*Response, error)

func (*Client) Client

func (c *Client) Client() *http.Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(m string, u string, b interface{}) (*http.Request, error)

func (*Client) NewURL

func (c *Client) NewURL(p string, v interface{}) (string, error)

func (*Client) WithAuthToken

func (c *Client) WithAuthToken(t string) *Client

type Credentials

type Credentials struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

type CredentialsError

type CredentialsError ResponseError

func (*CredentialsError) Error

func (e *CredentialsError) Error() string

type Episode

type Episode struct {
	EpisodeNumber *int    `json:"episode_number,omitempty"`
	FeatureID     *ID     `json:"feature_id,omitempty"`
	FeatureIMDBID *ID     `json:"feature_imdb_id,omitempty"`
	Title         *string `json:"title,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	ResponseError
	Errors []error
}

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type Feature

type Feature struct {
	EpisodeNumber   *int            `json:"episode_number,omitempty"`
	FeatureID       *ID             `json:"feature_id,omitempty"`
	FeatureType     *string         `json:"feature_type,omitempty"`
	IMDBID          *ID             `json:"imdb_id,omitempty"`
	IMGURL          *string         `json:"img_url,omitempty"`
	OriginalTitle   *string         `json:"original_title,omitempty"`
	ParentIMDBID    *ID             `json:"parent_imdb_id,omitempty"`
	ParentTitle     *string         `json:"parent_title,omitempty"`
	SeasonNumber    *int            `json:"season_number,omitempty"`
	Seasons         *Season         `json:"seasons,omitempty"`
	SeasonsCount    *int            `json:"seasons_count,omitempty"`
	SubtitlesCount  *int            `json:"subtitles_count,omitempty"`
	SubtitlesCounts *map[string]int `json:"subtitles_counts,omitempty"`
	Title           *string         `json:"title,omitempty"`
	TitleAka        []*string       `json:"title_aka,omitempty"`
	TMDBID          *ID             `json:"tmdb_id,omitempty"`
	URL             *string         `json:"url,omitempty"`
	Year            *string         `json:"year,omitempty"`
}

type FeatureDetails

type FeatureDetails struct {
	EpisodeNumber   *int    `json:"episode_number,omitempty"`
	FeatureID       *ID     `json:"feature_id,omitempty"`
	FeatureType     *string `json:"feature_type,omitempty"`
	IMDBID          *ID     `json:"imdb_id,omitempty"`
	MovieName       *string `json:"movie_name,omitempty"`
	ParentFeatureID *ID     `json:"parent_feature_id,omitempty"`
	ParentIMDBID    *ID     `json:"parent_imdb_id,omitempty"`
	ParentTitle     *string `json:"parent_title,omitempty"`
	ParentTMDBID    *ID     `json:"parent_tmdb_id,omitempty"`
	SeasonNumber    *int    `json:"season_number,omitempty"`
	Title           *string `json:"title,omitempty"`
	TMDBID          *ID     `json:"tmdb_id,omitempty"`
	Year            *int    `json:"year,omitempty"`
}

type FeatureEntity

type FeatureEntity struct {
	Attributes *Feature `json:"attributes,omitempty"`
	ID         *ID      `json:"id,omitempty"`
	Type       *string  `json:"type,omitempty"`
}

type FeaturesPopularParameters

type FeaturesPopularParameters struct {
	Languages []string `url:"languages,omitempty" del:","`
	Type      string   `url:"type,omitempty"`
}

type FeaturesSearchParameters

type FeaturesSearchParameters struct {
	FeatureID ID     `url:"feature_id,omitempty"`
	IMDBID    ID     `url:"imdb_id,omitempty"`
	Query     string `url:"query,omitempty"`
	TMDBID    ID     `url:"tmdb_id,omitempty"`
	Type      string `url:"type,omitempty"`
	Year      int    `url:"year,omitempty"`
}

type FeaturesService

type FeaturesService service

func (*FeaturesService) Popular

Discovers popular features, according to last 30 days downloads.

OpenSubtitles Reference

func (*FeaturesService) Search

Searches for features.

OpenSubtitles Reference

type File

type File struct {
	CDNumber *int    `json:"cd_number,omitempty"`
	FileID   *ID     `json:"file_id,omitempty"`
	FileName *string `json:"file_name,omitempty"`
}

type FileError

type FileError ResponseError

func (*FileError) Error

func (e *FileError) Error() string

type FormatsListResponse

type FormatsListResponse struct {
	OutputFormats []*string `json:"output_formats,omitempty"`
}

type FormatsService

type FormatsService service

func (*FormatsService) List

Lists subtitle formats.

OpenSubtitles Reference

type ID

type ID int64

The OpenSubtitles API is inconsistent as it may represent IDs in either string or int32. This type helps by casting any ID to int64 for consistency.

func AllocateID

func AllocateID(v int64) *ID

Allocates a new ID value to store v and returns a pointer to it.

func (*ID) EncodeValues

func (id *ID) EncodeValues(key string, v *url.Values) error

func (*ID) String

func (id *ID) String() string

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) error

type Language

type Language struct {
	LanguageCode *string `json:"language_code,omitempty"`
	LanguageName *string `json:"language_name,omitempty"`
}

type LanguagesService

type LanguagesService service

func (*LanguagesService) List

func (s *LanguagesService) List(ctx context.Context) ([]*Language, *Response, error)

Lists subtitle languages.

OpenSubtitles Reference

type LinkError

type LinkError ResponseError

func (*LinkError) Error

func (e *LinkError) Error() string

type Login

type Login struct {
	// Returns the base URL with the protocol and version, which can be utilized
	// with the SetBaseURL method of the Client. It is distinct from the BaseURL
	// because the latter includes the service host without the protocol and API
	// version.
	ClientBaseURL string `json:"-"`

	BaseURL *string `json:"base_url,omitempty"`
	Token   *string `json:"token,omitempty"`
	User    *User   `json:"user,omitempty"`
}

func (*Login) UnmarshalJSON

func (l *Login) UnmarshalJSON(data []byte) error

type Pagination

type Pagination struct {
	Page       int `json:"page"`
	PerPage    int `json:"per_page"`
	TotalCount int `json:"total_count"`
	TotalPages int `json:"total_pages"`
}

type Quota

type Quota struct {
	Remaining    int       `json:"remaining"`
	Requests     int       `json:"requests"`
	ResetTime    string    `json:"reset_time"`
	ResetTimeUTC time.Time `json:"reset_time_utc"`
}

type QuotaError

type QuotaError struct {
	ResponseError
	Quota
}

func (*QuotaError) Error

func (e *QuotaError) Error() string

type Rate

type Rate struct {
	Limit     int
	Remaining int
	Reset     int
}

type RateLimitError

type RateLimitError ResponseError

func (*RateLimitError) Error

func (e *RateLimitError) Error() string
type RelatedLink struct {
	IMGURL *string `json:"img_url,omitempty"`
	Label  *string `json:"label,omitempty"`
	URL    *string `json:"url,omitempty"`
}

type Response

type Response struct {
	*http.Response
	Pagination Pagination
	Quota      Quota
	Rate       Rate
}

type ResponseError

type ResponseError struct {
	Response *http.Response
	Message  string
}

func (*ResponseError) Error

func (e *ResponseError) Error() string

type Season

type Season struct {
	Episodes     []*Episode `json:"episodes,omitempty"`
	SeasonNumber *int       `json:"season_number,omitempty"`
}

type Subtitle

type Subtitle struct {
	AITranslated      *bool           `json:"ai_translated,omitempty"`
	Comments          *string         `json:"comments,omitempty"`
	DownloadCount     *int            `json:"download_count,omitempty"`
	FeatureDetails    *FeatureDetails `json:"feature_details,omitempty"`
	Files             []*File         `json:"files,omitempty"`
	ForeignPartsOnly  *bool           `json:"foreign_parts_only,omitempty"`
	FPS               *float32        `json:"fps,omitempty"`
	FromTrusted       *bool           `json:"from_trusted,omitempty"`
	HD                *bool           `json:"hd,omitempty"`
	HearingImpaired   *bool           `json:"hearing_impaired,omitempty"`
	Language          *string         `json:"language,omitempty"`
	MachineTranslated *bool           `json:"machine_translated,omitempty"`
	NewDownloadCount  *int            `json:"new_download_count,omitempty"`
	Ratings           *float32        `json:"ratings,omitempty"`
	RelatedLinks      []*RelatedLink  `json:"related_links,omitempty"`
	Release           *string         `json:"release,omitempty"`
	SubtitleID        *ID             `json:"subtitle_id,omitempty"`
	UploadDate        *time.Time      `json:"upload_date,omitempty"`
	Uploader          *Uploader       `json:"uploader,omitempty"`
	URL               *string         `json:"url,omitempty"`
	Votes             *int            `json:"votes,omitempty"`
}

type SubtitleEntity

type SubtitleEntity struct {
	Attributes *Subtitle `json:"attributes,omitempty"`
	ID         *ID       `json:"id,omitempty"`
	Type       *string   `json:"type,omitempty"`
}

type SubtitlesDownloadParameters

type SubtitlesDownloadParameters struct {
	FileID        ID     `json:"file_id,omitempty"`
	FileName      string `json:"file_name,omitempty"`
	ForceDownload bool   `json:"force_download,omitempty"`
	InFPS         int    `json:"in_fps,omitempty"`
	OutFPS        int    `json:"out_fps,omitempty"`
	SubFormat     string `json:"sub_format,omitempty"`
	Timeshift     int    `json:"timeshift,omitempty"`
}

type SubtitlesDownloadResponse

type SubtitlesDownloadResponse struct {
	FileName *string `json:"file_name,omitempty"`
	Link     *string `json:"link,omitempty"`
}

type SubtitlesLatestParameters

type SubtitlesLatestParameters struct {
	Languages []string `url:"languages,omitempty" del:","`
	Type      string   `url:"type,omitempty"`
}

type SubtitlesPopularParameters

type SubtitlesPopularParameters struct {
	Languages []string `url:"languages,omitempty" del:","`
	Type      string   `url:"type,omitempty"`
}

type SubtitlesSearchParameters

type SubtitlesSearchParameters struct {
	AITranslated      string   `url:"ai_translated,omitempty"`
	EpisodeNumber     int      `url:"episode_number,omitempty"`
	ForeignPartsOnly  string   `url:"foreign_parts_only,omitempty"`
	HearingImpaired   string   `url:"hearing_impaired,omitempty"`
	ID                ID       `url:"id,omitempty"`
	IMDBID            ID       `url:"imdb_id,omitempty"`
	Languages         []string `url:"languages,omitempty" del:","`
	MachineTranslated string   `url:"machine_translated,omitempty"`
	Moviehash         string   `url:"moviehash,omitempty"`
	MoviehashMatch    string   `url:"moviehash_match,omitempty"`
	OrderBy           string   `url:"order_by,omitempty"`
	OrderDirection    string   `url:"order_direction,omitempty"`
	Page              int      `url:"page,omitempty"`
	ParentFeatureID   ID       `url:"parent_feature_id,omitempty"`
	ParentIMDBID      ID       `url:"parent_imdb_id,omitempty"`
	ParentTMDBID      ID       `url:"parent_tmdb_id,omitempty"`
	Query             string   `url:"query,omitempty"`
	SeasonNumber      int      `url:"season_number,omitempty"`
	TMDBID            ID       `url:"tmdb_id,omitempty"`
	TrustedSources    string   `url:"trusted_sources,omitempty"`
	Type              string   `url:"type,omitempty"`
	UserID            ID       `url:"user_id,omitempty"`
	Year              int      `url:"year,omitempty"`
}

type SubtitlesService

type SubtitlesService service

func (*SubtitlesService) Download

Requests a download URL for a subtitles.

OpenSubtitles Reference

func (*SubtitlesService) Latest

Discovers the last uploaded subtitles.

OpenSubtitles Reference

func (*SubtitlesService) Popular

Discovers popular subtitles, according to last 30 days downloads.

OpenSubtitles Reference

func (*SubtitlesService) Search

Searches for subtitles.

OpenSubtitles Reference

type Uploader

type Uploader struct {
	Name       *string `json:"name,omitempty"`
	Rank       *string `json:"rank,omitempty"`
	UploaderID *ID     `json:"uploader_id,omitempty"`
}

type User

type User struct {
	AllowedDownloads    *int    `json:"allowed_downloads,omitempty"`
	AllowedTranslations *int    `json:"allowed_translations,omitempty"`
	DownloadsCount      *int    `json:"downloads_count,omitempty"`
	ExtInstalled        *bool   `json:"ext_installed,omitempty"`
	Level               *string `json:"level,omitempty"`
	RemainingDownloads  *int    `json:"remaining_downloads,omitempty"`
	UserID              *ID     `json:"user_id,omitempty"`
	Username            *string `json:"username,omitempty"`
	VIP                 *bool   `json:"vip,omitempty"`
}

type UserAgentError

type UserAgentError ResponseError

func (*UserAgentError) Error

func (e *UserAgentError) Error() string

type UsersService

type UsersService service

func (*UsersService) Get

func (s *UsersService) Get(ctx context.Context) (*User, *Response, error)

Gets a user's information.

OpenSubtitles Reference

Jump to

Keyboard shortcuts

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