Documentation
¶
Index ¶
- Variables
- func Hash(r io.ReadSeeker) (uint64, error)
- func HashString(hash uint64) string
- type Client
- func (c *Client) Download(fileID int, w io.Writer) error
- func (c *Client) DownloadSearch(q DownloadQuery) (*DownloadResponse, error)
- func (c *Client) Login() (*UserLogin, error)
- func (c *Client) Search(q SubtitleQueryParameters) ([]*SubtitleData, error)
- func (c *Client) SearchByFile(path string, langs []string) ([]*SubtitleData, error)
- func (c *Client) UserInfo() (*User, error)
- type DownloadQuery
- type DownloadResponse
- type FeatureDetails
- type File
- type RelatedLinks
- type Subtitle
- type SubtitleData
- type SubtitleQueryParameters
- type Uploader
- type User
- type UserLogin
Constants ¶
This section is empty.
Variables ¶
var ErrFileTooSmall = errors.New("opensubtitles: file too small")
ErrFileTooSmall is returned if the file is too small to compute a hash
Functions ¶
func HashString ¶
HashString returns the padded hexadecimal representation of a hash
Types ¶
type Client ¶
type Client struct { UserAgent string Endpoint string APIKey string Username string Password string Token *jwt.Token User *User }
Client represents a client to connect to opensubtitles
func (*Client) DownloadSearch ¶
func (c *Client) DownloadSearch(q DownloadQuery) (*DownloadResponse, error)
DownloadSearch searches for a subtitle to download
func (*Client) Search ¶
func (c *Client) Search(q SubtitleQueryParameters) ([]*SubtitleData, error)
Search searches subtitles using a raw query
func (*Client) SearchByFile ¶
func (c *Client) SearchByFile(path string, langs []string) ([]*SubtitleData, error)
SearchByFile searches subtitles by file
type DownloadQuery ¶
type DownloadQuery struct { FileID int `json:"file_id"` // mandatory SubFormat string `json:"sub_format"` FileName string `json:"file_name"` StripHTML bool `json:"strip_html"` CleanupLinks bool `json:"cleanup_links"` RemoveAdds bool `json:"remove_adds"` InFPS int `json:"in_fps"` OutFPS int `json:"out_fps"` Timeshift int `json:"timeshift"` }
DownloadQuery represents the query to download a subtitle
type DownloadResponse ¶
type DownloadResponse 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"` }
DownloadResponse represents the response when requesting for a file to download
type FeatureDetails ¶
type FeatureDetails struct { ID int `json:"feature_id"` Type 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 holds the details of the video this subtitle refers to
type File ¶
type File struct { ID int `json:"file_id"` CDNumber int `json:"cd_number"` FileName string `json:"file_name"` }
File represents a file
type RelatedLinks ¶
type RelatedLinks struct { Label string `json:"label"` URL string `json:"url"` ImgURL string `json:"img_url"` }
RelatedLinks holds some link
type Subtitle ¶
type Subtitle struct { ID string `json:"subtitle_id"` Language string `json:"language"` DownloadCount int `json:"download_count"` NewDownloadCount int `json:"new_download_count"` HearingImpared bool `json:"hearing_impared"` HD bool `json:"hd"` FPS float64 `json:"fps"` Votes int `json:"votes"` Points int `json:"points"` Rating int `json:"rating"` FromTrusted bool `json:"from_trusted"` ForeignPartsOnly bool `json:"foreign_parts_only"` AutoTranslation bool `json:"auto_translation"` AITranslated bool `json:"ai_translated"` UploadDate time.Time `json:"upload_date"` Release string `json:"release"` Comments string `json:"comments"` LegacySubtitleID int `json:"legacy_subtitle_id"` URL string `json:"url"` FeatureDetails FeatureDetails `json:"feature_details"` Uploader Uploader `json:"uploader"` RelatedLinks RelatedLinks `json:"related_links"` Files []File `json:"files"` MovieHashMatch bool `json:"movie_hash_match"` }
Subtitle represents a subtile response
type SubtitleData ¶
type SubtitleData struct { ID string `json:"id"` Type string `json:"type"` Subtitle Subtitle `json:"attributes"` }
SubtitleData holds the subtitle
type SubtitleQueryParameters ¶
type SubtitleQueryParameters struct { AITranslated string // ai_translated / exclude, include (default: exclude) EpisodeNumber int // episode_number ForeignPartsOnly string // foreign_parts_only / include, only (default: include) HearingImpaired string // hearing_impaired / include, exclude, only. (default: include) ID string // id ImdbID string // imdb_id without tt Languages []string // languages: coma separated (en,fr) MachineTranslated string // machine_translated MovieHash string // moviehash MovieHashMatch string // moviehash_match OrderBy string // order_by OrderDirection string // order_direction Page int // page ParentFeatureID int // parent_feature_id ParentImdbID int // parent_imdb_id ParentTmdbID int // parent_tmdb_id Query string // query string SeasonNumber int // season_number TmdbID string // tmdb_id TrustedSources string // trusted_sources / include, only (default: include) Type string // type / movie, episode or all, (default: all) UserID string // user_id Year int // year }
SubtitleQueryParameters represents the allowed search parameters
func (*SubtitleQueryParameters) Encode ¶
func (q *SubtitleQueryParameters) Encode() string
Encode encodes the query parameters
type Uploader ¶
type Uploader struct { ID int `json:"uploader_id"` Name string `json:"name"` Rank string `json:"rank"` }
Uploader represents an uploader
type User ¶
type User struct { AllowedDownloads int `json:"allowed_downloads"` Level string `json:"level"` ID int `json:"user_id"` ExtInstalled bool `json:"ext_installed"` VIP bool `json:"vip"` DownloadCount int `json:"download_count"` RemainingDownloads int `json:"remaining_downloads"` }
User represents the user