osdb

package
v0.0.0-...-29a3764 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultOSDBServer ...
	DefaultOSDBServer = "https://api.opensubtitles.org/xml-rpc"
	// DefaultUserAgent ...
	DefaultUserAgent = "XBMC_Subtitles_v1" // XBMC OpenSubtitles Agent
	// SearchLimit ...
	SearchLimit = 100
	// StatusSuccess ...
	StatusSuccess = "200 OK"
)

Variables

This section is empty.

Functions

func DoDownload

func DoDownload(file, dl string) (*os.File, string, error)

DoDownload ...

func Hash

func Hash(r io.ReaderAt, size int64) (string, error)

Hash ...

func HashFile

func HashFile(file *os.File) (string, error)

HashFile ...

func NewSubtitleReader

func NewSubtitleReader(s *Subtitle) (io.Reader, error)

NewSubtitleReader ...

Types

type Client

type Client struct {
	UserAgent string
	Token     string
	Login     string
	Password  string
	Language  string
	*xmlrpc.Client
}

Client ...

func NewClient

func NewClient() (*Client, error)

NewClient ...

func (*Client) Download

func (c *Client) Download(s *Subtitle) error

Download Save subtitle file to disk, using the OSDB specified name.

func (*Client) DownloadSubtitles

func (c *Client) DownloadSubtitles(ids []int) ([]SubtitleFile, error)

DownloadSubtitles Download subtitles by file ID.

func (*Client) DownloadTo

func (c *Client) DownloadTo(s *Subtitle, path string) (err error)

DownloadTo Save subtitle file to disk, using the specified path.

func (*Client) GetImdbMovieDetails

func (c *Client) GetImdbMovieDetails(id string) (*Movie, error)

GetImdbMovieDetails Get movie details from IMDB.

func (*Client) HasSubtitles

func (c *Client) HasSubtitles(subs Subtitles) (bool, error)

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

func (c *Client) HasSubtitlesForFiles(movieFile string, subFile string) (bool, error)

HasSubtitlesForFiles Checks whether OSDB already has subtitles for a movie and subtitle files.

func (*Client) LogIn

func (c *Client) LogIn(user string, pass string, lang string) (err error)

LogIn to the API, and return a session token.

func (*Client) LogOut

func (c *Client) LogOut() (err error)

LogOut ...

func (*Client) Noop

func (c *Client) Noop() (err error)

Noop Keep session alive

func (*Client) SearchOnImdb

func (c *Client) SearchOnImdb(q string) (Movies, error)

SearchOnImdb Search movies on IMDB.

func (*Client) SearchSubtitles

func (c *Client) SearchSubtitles(payloads []SearchPayload) (Subtitles, error)

SearchSubtitles ...

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 ...

type Movies

type Movies []Movie

Movies A collection of movies.

func (Movies) Empty

func (m Movies) Empty() bool

Empty ...

type SearchPayload

type SearchPayload struct {
	Query     string `xmlrpc:"query"`
	Hash      string `xmlrpc:"moviehash"`
	Size      int64  `xmlrpc:"moviebytesize"`
	IMDBId    string `xmlrpc:"imdbid"`
	Languages string `xmlrpc:"sublanguageid"`
}

SearchPayload ...

func GetPayloads

func GetPayloads(searchString string, languages []string, preferredLanguage string, showID int, playingFile string) ([]SearchPayload, string)

GetPayloads ...

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"`
	QueryParameters  struct {
		// contains filtered or unexported fields
	} `xmlrpc:"QueryParameters"`
	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"`
	SubEncoding        string `xmlrpc:"SubEncoding"`
	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"`
	SubLastTS          string `xmlrpc:"SubLastTS"`
	SubRating          string `xmlrpc:"SubRating"`
	SubSize            string `xmlrpc:"SubSize"`
	SubSumCD           string `xmlrpc:"SubSumCD"`
	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...

func NewSubtitleWithFile

func NewSubtitleWithFile(movieFile string, subFile string) (s Subtitle, err error)

NewSubtitleWithFile Build a Subtitle struct for a file, suitable for osdb.HasSubtitles()

type SubtitleFile

type SubtitleFile struct {
	ID   string `xmlrpc:"idsubtitlefile"`
	Data string `xmlrpc:"data"`
	// 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 *gzip.Reader, err error)

Reader for the subtitle file contents (decoded, and decompressed).

type Subtitles

type Subtitles []Subtitle

Subtitles A collection of subtitles

func DoSearch

func DoSearch(payloads []SearchPayload, preferredLanguage string) (Subtitles, error)

DoSearch ...

func (Subtitles) Best

func (subs Subtitles) Best() *Subtitle

Best ... The best subtitle of the collection, for some definition of "best" at least.

Jump to

Keyboard shortcuts

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