opensubtitles

package
v0.1.103 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoUser = errors.New("no OpenSubtitles username provided")
	ErrNoPass = errors.New("no OpenSubtitles password provided")
)

Functions

func Authorize

func Authorize() error

func DoDownload

func DoDownload(id string) (*os.File, string, string, error)

func GetAvailableHeader added in v0.1.102

func GetAvailableHeader() http.Header

func GetHeader

func GetHeader() http.Header

func Hash

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

Hash ...

func HashFile

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

HashFile ...

Types

type Attributes

type Attributes struct {
	SubtitleID        string         `json:"subtitle_id"`
	Language          string         `json:"language"`
	DownloadCount     int            `json:"download_count"`
	NewDownloadCount  int            `json:"new_download_count"`
	HearingImpaired   bool           `json:"hearing_impaired"`
	Hd                bool           `json:"hd"`
	Fps               float64        `json:"fps"`
	Votes             int            `json:"votes"`
	Ratings           float64        `json:"ratings"`
	FromTrusted       bool           `json:"from_trusted"`
	ForeignPartsOnly  bool           `json:"foreign_parts_only"`
	UploadDate        time.Time      `json:"upload_date"`
	AiTranslated      bool           `json:"ai_translated"`
	NbCd              int            `json:"nb_cd"`
	MachineTranslated bool           `json:"machine_translated"`
	MovieHashMatch    bool           `json:"moviehash_match"`
	Release           string         `json:"release"`
	Comments          string         `json:"comments"`
	LegacySubtitleID  int            `json:"legacy_subtitle_id"`
	LegacyUploaderID  int            `json:"legacy_uploader_id"`
	Uploader          Uploader       `json:"uploader"`
	FeatureDetails    FeatureDetails `json:"feature_details"`
	URL               string         `json:"url"`
	RelatedLinks      []RelatedLinks `json:"related_links"`
	Files             []File         `json:"files"`
}

type DownloadErrorResponse added in v0.1.102

type DownloadErrorResponse struct {
	Requests     int       `json:"requests"`
	Remaining    int       `json:"remaining"`
	Message      string    `json:"message"`
	ResetTime    string    `json:"reset_time"`
	ResetTimeUtc time.Time `json:"reset_time_utc"`
	UK           string    `json:"uk"`
	UID          int       `json:"uid"`
	TS           int       `json:"ts"`
}

type DownloadResponse

type DownloadResponse struct {
	Link         string    `json:"link"`
	FileName     string    `json:"file_name"`
	Requests     int       `json:"requests"`
	Remaining    int       `json:"remaining"`
	Message      string    `json:"message"`
	ResetTime    string    `json:"reset_time"`
	ResetTimeUtc time.Time `json:"reset_time_utc"`
	Uk           string    `json:"uk"`
	UID          int       `json:"uid"`
	TS           int       `json:"ts"`
}

func DownloadSubtitles

func DownloadSubtitles(id string) (resp DownloadResponse, err error)

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"`
}

type File

type File struct {
	FileID   int    `json:"file_id"`
	CdNumber int    `json:"cd_number"`
	FileName string `json:"file_name"`
}

type LoginPayload

type LoginPayload struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type LoginResponse

type LoginResponse struct {
	User    User   `json:"user"`
	Token   string `json:"token"`
	Status  int    `json:"status"`
	BaseURL string `json:"base_url"`
}
type RelatedLinks struct {
	Label  string `json:"label"`
	URL    string `json:"url"`
	ImgURL string `json:"img_url"`
}

type SearchPayload

type SearchPayload struct {
	Type      string `json:"type"`
	Year      int    `json:"year"`
	Season    int    `json:"season"`
	Episode   int    `json:"episode"`
	Query     string `json:"query"`
	Hash      string `json:"moviehash"`
	IMDBId    string `json:"imdb_id"`
	TMDBId    string `json:"tmdb_id"`
	Languages string `json:"languages"`
}

func GetPayloads

func GetPayloads(xbmcHost *xbmc.XBMCHost, searchString string, languages []string, preferredLanguage string, showID int, playingFile string) ([]SearchPayload, string)

GetPayloads ...

type SearchResponse

type SearchResponse struct {
	TotalPages int                  `json:"total_pages"`
	TotalCount int                  `json:"total_count"`
	PerPage    int                  `json:"per_page"`
	Page       int                  `json:"page"`
	Data       []SearchResponseData `json:"data"`
}

type SearchResponseData

type SearchResponseData struct {
	ID         string     `json:"id"`
	Type       string     `json:"type"`
	Attributes Attributes `json:"attributes"`
}

func DoSearch

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

func SearchSubtitles

func SearchSubtitles(payloads []SearchPayload) (results []SearchResponseData, err error)

type Uploader

type Uploader struct {
	UploaderID any    `json:"uploader_id"`
	Name       string `json:"name"`
	Rank       string `json:"rank"`
}

type User

type User struct {
	AllowedTranslations int    `json:"allowed_translations"`
	AllowedDownloads    int    `json:"allowed_downloads"`
	Level               string `json:"level"`
	UserID              int    `json:"user_id"`
	ExtInstalled        bool   `json:"ext_installed"`
	Vip                 bool   `json:"vip"`
}

Jump to

Keyboard shortcuts

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