Documentation
¶
Overview ¶
Package osdb is an API client for opensubtitles.org
This is a client for the OSDb protocol. Currently the package only allows movie identification, subtitles search, and download.
Index ¶
- Constants
- func Hash(path string) (uint64, error)
- func HashFile(file *os.File) (hash uint64, err error)
- type ByDownloads
- type Client
- func (c *Client) BestMoviesByHashes(hashes []uint64) ([]*Movie, error)
- func (c *Client) Download(s *Subtitle) error
- func (c *Client) DownloadSubtitles(subtitles Subtitles) ([]SubtitleFile, error)
- func (c *Client) DownloadSubtitlesByIds(ids []int) ([]SubtitleFile, error)
- func (c *Client) DownloadTo(s *Subtitle, path string) (err error)
- func (c *Client) FileSearch(path string, langs []string) (Subtitles, error)
- func (c *Client) GetIMDBMovieDetails(id string) (*Movie, error)
- func (c *Client) HasSubtitles(subs Subtitles) (bool, error)
- func (c *Client) HasSubtitlesForFiles(movieFile string, subFile string) (bool, error)
- func (c *Client) IMDBSearch(q string) (Movies, error)
- func (c *Client) IMDBSearchByID(ids []string, langs []string) (Subtitles, error)
- func (c *Client) LogIn(user string, pass string, lang string) (err error)
- func (c *Client) LogOut() (err error)
- func (c *Client) Noop() (err error)
- func (c *Client) SearchSubtitles(params *[]interface{}) (Subtitles, error)
- type Movie
- type Movies
- type Subtitle
- type SubtitleFile
- type Subtitles
Constants ¶
const ( // DefaultOSDBServer is OSDB's API base URL. DefaultOSDBServer = "https://api.opensubtitles.org:443/xml-rpc" // DefaultUserAgent is the current version of this lib. DefaultUserAgent = "osdb-go 0.2" // SearchLimit = nax hits per search SearchLimit = 100 // StatusSuccess is the successful response status for API calls. StatusSuccess = "200 OK" )
const (
// ChunkSize = 64k
ChunkSize = 65536
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ByDownloads ¶
type ByDownloads Subtitles
ByDownloads implements sort interface for Subtitles, by download count.
func (ByDownloads) Len ¶
func (s ByDownloads) Len() int
func (ByDownloads) Less ¶
func (s ByDownloads) Less(i, j int) bool
func (ByDownloads) Swap ¶
func (s ByDownloads) Swap(i, j int)
type Client ¶
type Client struct {
UserAgent string
Token string
Login string
Password string
Language string
*xmlrpc.Client
}
Client wraps an XML-RPC client to connect to OSDB.
func (*Client) BestMoviesByHashes ¶
BestMoviesByHashes searches for the best matching movies for each of the hashes (only for <200). This returns incomplete Movies, with the following fields only: ID, Title and Year.
func (*Client) DownloadSubtitles ¶
func (c *Client) DownloadSubtitles(subtitles Subtitles) ([]SubtitleFile, error)
DownloadSubtitles downloads subtitles in bulk.
func (*Client) DownloadSubtitlesByIds ¶
func (c *Client) DownloadSubtitlesByIds(ids []int) ([]SubtitleFile, error)
DownloadSubtitlesByIds downloads subtitles by ID.
func (*Client) DownloadTo ¶
DownloadTo saves a subtitle file to the specified path.
func (*Client) FileSearch ¶
FileSearch searches subtitles for a file and list of languages.
func (*Client) GetIMDBMovieDetails ¶
GetIMDBMovieDetails fetches movie details from IMDB by ID.
func (*Client) HasSubtitles ¶
HasSubtitles checks whether subtitles already exists in OSDB. The mandatory fields in the received Subtitle slice are: SubHash, SubFileName, MovieHash, MovieByteSize, and MovieFileName.
func (*Client) HasSubtitlesForFiles ¶
HasSubtitlesForFiles checks whether OSDB already has subtitles for a movie and subtitle files.
func (*Client) IMDBSearch ¶
IMDBSearch searches movies on IMDB.
func (*Client) IMDBSearchByID ¶
IMDBSearchByID searches subtitles that match some IMDB IDs.
func (*Client) SearchSubtitles ¶
SearchSubtitles searches OSDB with your own parameters.
type Movie ¶
type Movie struct {
ID string `xmlrpc:"id"`
Title string `xmlrpc:"title"`
Cover string `xmlrpc:"cover"`
Year string `xmlrpc:"year"`
Duration string `xmlrpc:"duration"`
TagLine string `xmlrpc:"tagline"`
Plot string `xmlrpc:"plot"`
Goofs string `xmlrpc:"goofs"`
Trivia string `xmlrpc:"trivia"`
Cast map[string]string `xmlrpc:"cast"`
Directors map[string]string `xmlrpc:"directors"`
Writers map[string]string `xmlrpc:"writers"`
Awards string `xmlrpc:"awards"`
Genres []string `xmlrpc:"genres"`
Countries []string `xmlrpc:"country"`
Languages []string `xmlrpc:"language"`
Certifications []string `xmlrpc:"certification"`
}
Movie is a type that stores the information from IMDB searches.
type Subtitle ¶
type Subtitle struct {
IDMovie string `xmlrpc:"IDMovie"`
IDMovieImdb string `xmlrpc:"IDMovieImdb"`
IDSubMovieFile string `xmlrpc:"IDSubMovieFile"`
IDSubtitle string `xmlrpc:"IDSubtitle"`
IDSubtitleFile string `xmlrpc:"IDSubtitleFile"`
ISO639 string `xmlrpc:"ISO639"`
LanguageName string `xmlrpc:"LanguageName"`
MatchedBy string `xmlrpc:"MatchedBy"`
MovieByteSize string `xmlrpc:"MovieByteSize"`
MovieFPS string `xmlrpc:"MovieFPS"`
MovieHash string `xmlrpc:"MovieHash"`
MovieImdbRating string `xmlrpc:"MovieImdbRating"`
MovieKind string `xmlrpc:"MovieKind"`
MovieName string `xmlrpc:"MovieName"`
MovieNameEng string `xmlrpc:"MovieNameEng"`
MovieReleaseName string `xmlrpc:"MovieReleaseName"`
MovieTimeMS string `xmlrpc:"MovieTimeMS"`
MovieYear string `xmlrpc:"MovieYear"`
MovieFileName string `xmlrpc:"MovieName"`
QueryNumber string `xmlrpc:"QueryNumber"`
SeriesEpisode string `xmlrpc:"SeriesEpisode"`
SeriesIMDBParent string `xmlrpc:"SeriesIMDBParent"`
SeriesSeason string `xmlrpc:"SeriesSeason"`
SubActualCD string `xmlrpc:"SubActualCD"`
SubAddDate string `xmlrpc:"SubAddDate"`
SubAuthorComment string `xmlrpc:"SubAuthorComment"`
SubBad string `xmlrpc:"SubBad"`
SubComments string `xmlrpc:"SubComments"`
SubDownloadLink string `xmlrpc:"SubDownloadLink"`
SubDownloadsCnt string `xmlrpc:"SubDownloadsCnt"`
SubFeatured string `xmlrpc:"SubFeatured"`
SubFileName string `xmlrpc:"SubFileName"`
SubFormat string `xmlrpc:"SubFormat"`
SubHash string `xmlrpc:"SubHash"`
SubHD string `xmlrpc:"SubHD"`
SubHearingImpaired string `xmlrpc:"SubHearingImpaired"`
SubLanguageID string `xmlrpc:"SubLanguageID"`
SubRating string `xmlrpc:"SubRating"`
SubSize string `xmlrpc:"SubSize"`
SubSumCD string `xmlrpc:"SubSumCD"`
SubEncoding string `xmlrpc:"SubEncoding"`
SubtitlesLink string `xmlrpc:"SubtitlesLink"`
UserID string `xmlrpc:"UserID"`
UserNickName string `xmlrpc:"UserNickName"`
UserRank string `xmlrpc:"UserRank"`
ZipDownloadLink string `xmlrpc:"ZipDownloadLink"`
}
A Subtitle with its many OSDB attributes...
type SubtitleFile ¶
type SubtitleFile struct {
ID string `xmlrpc:"idsubtitlefile"`
Data string `xmlrpc:"data"`
Encoding encoding.Encoding
// contains filtered or unexported fields
}
SubtitleFile contains file data as returned by OSDB's API, that is to say: gzip-ped and base64-encoded text.
func (*SubtitleFile) Reader ¶
func (sf *SubtitleFile) Reader() (r io.ReadCloser, err error)
Reader interface for SubtitleFile. Subtitle's contents are decompressed, and usually encoded to UTF-8: if encoding info is missing, no re-encoding is done.