Documentation ¶
Index ¶
- func CheckResponse(r *http.Response, b []byte) error
- type Attributes
- type AttributesFeature
- type AuthenticationService
- type Client
- type Credentials
- type Data
- type DiscoverService
- type Download
- type DownloadOptions
- type DownloadService
- type ErrorResponse
- type Feature
- type FeatureData
- type FeatureDetails
- type FeatureOptions
- type Files
- type FindOptions
- type FindService
- type Formats
- type FormatsData
- type InfoService
- func (s *InfoService) Formats(ctx context.Context) (formats *Formats, resp *http.Response, err error)
- func (s *InfoService) Languages(ctx context.Context) (languages *Languages, resp *http.Response, err error)
- func (s *InfoService) User(ctx context.Context) (user *User, resp *http.Response, err error)
- type Languages
- type LanguagesData
- type LoggedIn
- type RelatedLinks
- type SearchOptions
- type SearchService
- func (s *SearchService) Movie(ctx context.Context, opt *SearchOptions) (shows *Shows, resp *http.Response, err error)
- func (s *SearchService) TV(ctx context.Context, opt *SearchOptions) (shows *Shows, resp *http.Response, err error)
- func (s *SearchService) Title(ctx context.Context, opt *SearchOptions) (shows *Shows, resp *http.Response, err error)
- type Show
- type ShowAttributes
- type Shows
- type Subtitles
- type SubtitlesCounts
- type SubtitlesOptions
- type Uploader
- type User
- type UserData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range or equal to 202 Accepted. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
Types ¶
type Attributes ¶
type Attributes struct { Language string `json:"language"` DownloadCount int `json:"download_count"` NewDownloadCount int `json:"new_download_count"` HearingImpaired bool `json:"hearing_impaired"` Hd bool `json:"hd"` Format interface{} `json:"format"` Fps float64 `json:"fps"` Votes int `json:"votes"` Points int `json:"points"` Ratings float64 `json:"ratings"` FromTrusted bool `json:"from_trusted"` AutoTranslation bool `json:"auto_translation"` AiTranslated bool `json:"ai_translated"` MachineTranslated interface{} `json:"machine_translated"` UploadDate time.Time `json:"upload_date"` FileHashes []string `json:"file_hashes"` Release string `json:"release"` Comments string `json:"comments"` LegacySubtitleID int `json:"legacy_subtitle_id"` Uploader Uploader `json:"uploader"` FeatureDetails FeatureDetails `json:"feature_details"` URL string `json:"url"` RelatedLinks RelatedLinks `json:"related_links"` Files []Files `json:"files"` SubtitleID string `json:"subtitle_id"` }
Attributes for a given Subtitle
type AttributesFeature ¶
type AttributesFeature struct { Title string `json:"title"` OriginalTitle string `json:"original_title"` Year string `json:"year"` SubtitlesCounts SubtitlesCounts `json:"subtitles_counts"` SubtitlesCount int `json:"subtitles_count"` SeasonsCount int `json:"seasons_count"` ParentTitle string `json:"parent_title"` SeasonNumber int `json:"season_number"` EpisodeNumber interface{} `json:"episode_number"` ImdbID int `json:"imdb_id"` TmdbID int `json:"tmdb_id"` ParentImdbID interface{} `json:"parent_imdb_id"` FeatureID string `json:"feature_id"` TitleAka []string `json:"title_aka"` FeatureType string `json:"feature_type"` URL string `json:"url"` ImgURL string `json:"img_url"` Seasons []interface{} `json:"seasons"` }
AttributesFeature is the detail for a given movie or tv contains in FeatureData
type AuthenticationService ¶
type AuthenticationService service
AuthenticationService provides access to the login related functions in the OpenSubtitles API.
OpenSubtitles API docs: https://www.opensubtitles.com/docs/api/html/index.htm#authentication
func (*AuthenticationService) Login ¶
func (s *AuthenticationService) Login(ctx context.Context, opt *Credentials) (loggedIn *LoggedIn, resp *http.Response, err error)
Login endpoint provides an authentication token to the rest of the API
The response will return an token which should be included in all API requests to the server in a header that looks like the following:
Authorization: your-auth-token
type Client ¶
type Client struct { // Base URL for API requests. BaseURL *url.URL // Base URL for uploading files. UploadURL *url.URL // User agent used when communicating with the OpenSubtitles API. UserAgent string Credential Credentials Token string // Services used for talking to different parts of the OpenSubtitles API. Authentication *AuthenticationService Discover *DiscoverService Download *DownloadService Find *FindService Info *InfoService Search *SearchService // contains filtered or unexported fields }
A Client manages communication with the OpenSubtitles API.
func NewClient ¶
func NewClient(httpClient *http.Client, token string, cred Credentials) (c *Client)
NewClient returns a new OpenSubtitles API client. If a nil httpClient is provided, a new http.Client will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).
func (*Client) Connect ¶
Connect return a new Client with a working token by making the authentication with the Authentication Login function.
func (*Client) Do ¶
func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (resp *http.Response, err error)
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it. If rate limit is exceeded and reset time is in the future, Do returns *RateLimitError immediately without making a network API call.
The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.
type Credentials ¶
Credentials used to authenticate to make requests to the OpenSubtitles API.
type Data ¶
type Data struct { ID string `json:"id"` Type string `json:"type"` Attributes Attributes `json:"attributes"` }
Data is not documented currently
type DiscoverService ¶
type DiscoverService service
DiscoverService provides access to the discover related functions in the OpenSubtitles API.
OpenSubtitles API docs: https://www.opensubtitles.com/docs/api/html/index.htm#discover
func (*DiscoverService) MostDownloaded ¶
func (s *DiscoverService) MostDownloaded(ctx context.Context, opt *SubtitlesOptions) (sub *Subtitles, resp *http.Response, err error)
MostDownloaded list the most downloaded subtitles OpenSubtitles API docs : https://www.opensubtitles.com/docs/api/html/index.htm#find-most-downloaded-movie-subtitles
func (*DiscoverService) Popular ¶
func (s *DiscoverService) Popular(ctx context.Context, opt *SubtitlesOptions) (subtitles *Data, resp *http.Response, err error)
Popular list movies with most subtitles downloads OpenSubtitles API docs : https://www.opensubtitles.com/docs/api/html/index.htm#find-most-downloaded-movie-subtitles
type Download ¶
type Download struct { Link string `json:"link"` Fname string `json:"fname"` Requests int `json:"requests"` Allowed int `json:"allowed"` Remaining int `json:"remaining"` Message string `json:"message"` }
Download is the return of DownloadService.Download
type DownloadOptions ¶
type DownloadOptions struct { //ID of the file to download FileID int `url:"file_id,omitempty"` //Format (optional, default to original. possible values: srt, sub, mpl, webvtt, dfxp, txt) SubFormat string `url:"sub_format,omitempty"` //Desired name of the returned file FileName string `url:"file_name,omitempty"` //Remove HTML tags (default false) StripHTML string `url:"strip_html,omitempty"` //Remove HTML links CleanupLinks string `url:"cleanup_links,omitempty"` //Remove ads RemoveAds string `url:"remove_adds,omitempty"` //Input FPS (advanced, default to original subtitle FPS) InFPS string `url:"in_fps,omitempty"` //Output FPS OutFPS string `url:"out_fps,omitempty"` //Timeshift (+/- time in ms or s, eg +2s or -200ms) Timeshift string `url:"timeshift,omitempty"` }
DownloadOptions contains the parameters for the DownloadService.Download
type DownloadService ¶
type DownloadService service
DownloadService provides access to the download related functions in the OpenSubtitles API.
OpenSubtitles API docs: https://www.opensubtitles.com/docs/api/html/index.htm#download
func (*DownloadService) Download ¶
func (s *DownloadService) Download(ctx context.Context, opt *DownloadOptions) (download *Download, resp *http.Response, err error)
Download file specified by an id OpenSubtitles API docs : https://www.opensubtitles.com/docs/api/html/index.htm#download-subtitle-file
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response Errors []string `json:"errors"` Status int `json:"status"` }
ErrorResponse contains the http response, the list of Errors and the status
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type Feature ¶
type Feature struct {
Data []FeatureData `json:"data"`
}
Feature contains the details returned by FindService.Feature
type FeatureData ¶
type FeatureData struct { ID string `json:"id"` Type string `json:"type"` Attributes AttributesFeature `json:"attributes"` }
FeatureData contains the detail for only a given ID, be it a tv or show
type FeatureDetails ¶
type FeatureDetails struct { FeatureID int `json:"feature_id"` FeatureType string `json:"feature_type"` Year int `json:"year"` Title string `json:"title"` MovieName string `json:"movie_name"` ImdbID int `json:"imdb_id"` TmdbID int `json:"tmdb_id"` }
FeatureDetails provides the IMDB and TMDB ID among other basic description details
type FeatureOptions ¶
type FeatureOptions struct { //Feature ID of the feature ID string `url:"id,omitempty"` //IMDB ID of the feature ImdbID string `url:"imdb_id,omitempty"` //TMDB ID of the feature TmdbID string `url:"tmdb_id,omitempty"` }
FeatureOptions provide the parameters for FindService.Feature
type Files ¶
type Files struct { ID int `json:"id"` CdNumber int `json:"cd_number"` FileName string `json:"file_name"` }
Files is not documented currently
type FindOptions ¶
type FindOptions struct { //Feature ID of the feature ID string `url:"id,omitempty"` //IMDB ID of the feature ImdbID string `url:"imdb_id,omitempty"` //TMDB ID of the feature TmdbID string `url:"tmdb_id,omitempty"` //movie, episode or all, (default: all) Type string `url:"type,omitempty"` //file name or text search Query string `url:"query,omitempty"` //Language code(s), coma separated (en,fr) Languages string `url:"languages,omitempty"` //Moviehash of the movie MovieHash string `url:"moviehash,omitempty"` //To be used alone - for user uploads listing UserID string `url:"user_id,omitempty"` //include, exclude, only.(default: include) HearingImpaired string `url:"hearing_impaired,omitempty"` //include, only (default: include) TrustedSources string `url:"trusted_sources,omitempty"` //exclude, include (default: exclude) MachineTranslated string `url:"machine_translated,omitempty"` //exclude, include (default: exclude) AiTranslated string `url:"ai_translated,omitempty"` //Order of the returned results, accept any of above fields OrderBy string `url:"order_by,omitempty"` //Order direction of the returned results (asc, desc) OrderDirection string `url:"order_direction,omitempty"` }
FindOptions provide the parameters for FindService.Find
type FindService ¶
type FindService service
FindService provides access to the find related functions in the OpenSubtitles API.
OpenSubtitles API docs: https://www.opensubtitles.com/docs/api/html/index.htm#find
func (*FindService) Feature ¶
func (s *FindService) Feature(ctx context.Context, opt *FeatureOptions) (feature *Feature, resp *http.Response, err error)
Feature find details for a movie or tv serie specified by an ID. OpenSubtitles API docs : https://www.opensubtitles.com/docs/api/html/index.htm#find-details-for-a-feature
func (*FindService) Find ¶
func (s *FindService) Find(ctx context.Context, opt *FindOptions) (feature *Feature, resp *http.Response, err error)
Find subtitles for a movie specified by an ID or by sending his file name and moviehash OpenSubtitles API docs : https://www.opensubtitles.com/docs/api/html/index.htm#find-subtitles-by-id OpenSubtitles API docs : https://www.opensubtitles.com/docs/api/html/index.htm#find-subtitles-for-a-video-file
type Formats ¶
type Formats struct {
Data FormatsData `json:"data"`
}
Formats contains the list of all available formats
type FormatsData ¶
type FormatsData struct {
OutputFormats []string `json:"output_formats"`
}
FormatsData is contain in the Formats struct
type InfoService ¶
type InfoService service
InfoService provides access to the info related functions in the OpenSubtitles API.
OpenSubtitles API docs: https://www.opensubtitles.com/docs/api/html/index.htm#infos
func (*InfoService) Formats ¶
func (s *InfoService) Formats(ctx context.Context) (formats *Formats, resp *http.Response, err error)
Formats return a list of subtitles formats that can be processed by our system OpenSubtitles API docs : https://www.opensubtitles.com/docs/api/html/index.htm#list-subtitle-formats
func (*InfoService) Languages ¶
func (s *InfoService) Languages(ctx context.Context) (languages *Languages, resp *http.Response, err error)
Languages get the languages used on opensubtitles and their codes OpenSubtitles API docs : https://www.opensubtitles.com/docs/api/html/index.htm#get-the-languages-table
func (*InfoService) User ¶
User get user ID, level, total and remaining download quota OpenSubtitles API docs : https://www.opensubtitles.com/docs/api/html/index.htm#get-user-data
type Languages ¶
type Languages struct {
Data []LanguagesData `json:"data"`
}
Languages contains all the LanguagesData
type LanguagesData ¶
type LanguagesData struct { LanguageCode string `json:"language_code"` LanguageName string `json:"language_name"` }
LanguagesData associates a code to a name
type LoggedIn ¶
type LoggedIn struct { User UserData `json:"user"` Token string `json:"token"` Status int `json:"status"` }
LoggedIn is return when the AuthenticationService.Login is returned with a success
type RelatedLinks ¶
type RelatedLinks struct { Label string `json:"label"` URL string `json:"url"` ImgURL string `json:"img_url"` }
RelatedLinks is not documented currently
type SearchOptions ¶
type SearchOptions struct { //Title Query string `url:"query,omitempty"` }
SearchOptions contains the url parameter for the SearchService
type SearchService ¶
type SearchService service
SearchService provides access to the search related functions in the OpenSubtitles API.
OpenSubtitles API docs: https://www.opensubtitles.com/docs/api/html/index.htm#search
func (*SearchService) Movie ¶
func (s *SearchService) Movie(ctx context.Context, opt *SearchOptions) (shows *Shows, resp *http.Response, err error)
Movie search a movie by name OpenSubtitles API docs : https://www.opensubtitles.com/docs/api/html/index.htm#search-for-a-movie
func (*SearchService) TV ¶
func (s *SearchService) TV(ctx context.Context, opt *SearchOptions) (shows *Shows, resp *http.Response, err error)
TV search a TV serie by name OpenSubtitles API docs : https://www.opensubtitles.com/docs/api/html/index.htm#search-for-a-tv-serie
func (*SearchService) Title ¶
func (s *SearchService) Title(ctx context.Context, opt *SearchOptions) (shows *Shows, resp *http.Response, err error)
Title search for a feature by title (tv serie or movie) OpenSubtitles API docs : https://www.opensubtitles.com/docs/api/html/index.htm#search-for-a-feature-by-title
type Show ¶
type Show struct { ID string `json:"id"` Type string `json:"type"` Attributes ShowAttributes `json:"attributes"` }
Show represent a movie or a tv show
type ShowAttributes ¶
type ShowAttributes struct { Title string `json:"title"` OriginalTitle string `json:"original_title"` ImdbID int `json:"imdb_id"` TmdbID int `json:"tmdb_id"` FeatureID string `json:"feature_id"` Year string `json:"year"` TitleAka []string `json:"title_aka"` SubtitlesCounts SubtitlesCounts `json:"subtitles_counts"` URL string `json:"url"` ImgURL string `json:"img_url"` }
ShowAttributes represent the default show attributes
type Shows ¶
type Shows struct {
Data []Show `json:"data"`
}
Shows represent a list of tv show or movies
type Subtitles ¶
type Subtitles struct { TotalPages int `json:"total_pages"` TotalCount int `json:"total_count"` Page int `json:"page"` Data []Data `json:"data"` }
Subtitles is all the subtitles for a given file/show
type SubtitlesCounts ¶
type SubtitlesCounts struct { Pl int `json:"pl"` En int `json:"en"` Tr int `json:"tr"` Ro int `json:"ro"` Cs int `json:"cs"` Es int `json:"es"` PtBR int `json:"pt-BR"` Sl int `json:"sl"` PtPT int `json:"pt-PT"` Sr int `json:"sr"` El int `json:"el"` Bg int `json:"bg"` He int `json:"he"` Nl int `json:"nl"` Fi int `json:"fi"` Fr int `json:"fr"` Hu int `json:"hu"` Ar int `json:"ar"` Ru int `json:"ru"` Hr int `json:"hr"` Da int `json:"da"` Et int `json:"et"` Sv int `json:"sv"` Sq int `json:"sq"` Bs int `json:"bs"` De int `json:"de"` It int `json:"it"` Ko int `json:"ko"` No int `json:"no"` Fa int `json:"fa"` Sk int `json:"sk"` Mk int `json:"mk"` ZhCN int `json:"zh-CN"` Ms int `json:"ms"` ZhTW int `json:"zh-TW"` Bn int `json:"bn"` ID int `json:"id"` Lt int `json:"lt"` Is int `json:"is"` Ja int `json:"ja"` Th int `json:"th"` Ca int `json:"ca"` Hi int `json:"hi"` Ml int `json:"ml"` Mn int `json:"mn"` Vi int `json:"vi"` }
SubtitlesCounts return the subtitle count by language
type SubtitlesOptions ¶
type SubtitlesOptions struct { //All, or language code Language string `url:"language,omitempty"` //Type (movie or tvshow) Type string `url:"type,omitempty"` }
SubtitlesOptions is used for the discover API
type UserData ¶
type UserData struct { Jti string `json:"jti"` AllowedDownloads int `json:"allowed_downloads"` Level string `json:"level"` UserID int `json:"user_id"` ExtInstalled bool `json:"ext_installed"` Vip bool `json:"vip"` RemainingDownloads int `json:"remaining_downloads"` }
UserData represent all the information of a User