subtitles

package
v0.4.2-0...-e254bae Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAPIs = Clients{
	SubDB(),
	OpenSubtitles(),
	Addic7ed(),
}

DefaultAPIs represents the available APIs Is also used as the default

View Source
var Languages = Langs{}/* 475 elements not displayed */

Languages is the list of all languages

Functions

func Download

func Download(videoPath string, apiAliases []string, languages []string, notify bool) error

Download the subtitle from the video identified by its path

Types

type Addic7edAPI

type Addic7edAPI struct {
	Name    string
	Aliases []string
}

Addic7edAPI is the endpoint for downloading Addic7ed subtitles

func Addic7ed

func Addic7ed() Addic7edAPI

Addic7ed creates a new API for Addic7ed

func (Addic7edAPI) Download

func (s Addic7edAPI) Download(videoPath string, language Language) (subtitlePath string, err error)

Download downloads the Addic7ed subtitle from a video

func (Addic7edAPI) GetAliases

func (s Addic7edAPI) GetAliases() []string

GetAliases returns aliases to identify this API

func (Addic7edAPI) GetName

func (s Addic7edAPI) GetName() string

GetName returns the name of the api

func (Addic7edAPI) Upload

func (s Addic7edAPI) Upload(subtitlePath string, language Language, videoPath string) error

Upload uploads the subtitle to OpenSubtitles, for the given video

type ByName

type ByName []Language

ByName implements sort.Interface for []Language based on the Description field.

func (ByName) Len

func (a ByName) Len() int

func (ByName) Less

func (a ByName) Less(i, j int) bool

func (ByName) Swap

func (a ByName) Swap(i, j int)

type Client

type Client interface {
	Download(videoPath string, language Language) (subtitlePath string, err error)
	Upload(subtitlePath string, language Language, videoPath string) error
	GetName() string
	GetAliases() []string
}

Client defines the interface to get subtitles from API

type Clients

type Clients []Client

Clients is a slice of Client

func InitAPIs

func InitAPIs(apiAliases []string) (apis Clients)

InitAPIs sets the order of APIs search from apiAliases If alias does not exists, it is not included

func (Clients) Print

func (c Clients) Print()

Print prints the clients as nice table

func (Clients) String

func (c Clients) String() (s string)

String prints a nice representation of clients

type Langs

type Langs []Language

Langs is the type for a list of languages

func (Langs) GetDescriptions

func (l Langs) GetDescriptions() (descriptions []string)

GetDescriptions give the descriptions of the languages, as a list

func (Langs) GetLanguage

func (l Langs) GetLanguage(id string) (lang *Language)

GetLanguage get the language from an id

func (Langs) GetLanguages

func (l Langs) GetLanguages(ids []string) Langs

GetLanguages gets a list of languages, from a list of ids representing a language

func (Langs) Print

func (l Langs) Print(all bool)

Print prints the languages

type Language

type Language struct {
	ID          string   // ID
	Alias       []string // Available alias (as input for Subify)
	Description string   // Description of the language
}

Language defines a recognized language for

type OSDBAPI

type OSDBAPI struct {
	Name    string
	Aliases []string
}

OSDBAPI entry point

func OpenSubtitles

func OpenSubtitles() OSDBAPI

OpenSubtitles creates a new API for OpenSubtitles

func (OSDBAPI) Download

func (s OSDBAPI) Download(videoPath string, language Language) (subtitlePath string, err error)

Download downloads the OpenSubtitles subtitle from a video

func (OSDBAPI) GetAliases

func (s OSDBAPI) GetAliases() []string

GetAliases returns aliases to identify this API

func (OSDBAPI) GetName

func (s OSDBAPI) GetName() string

GetName returns the name of the api

func (OSDBAPI) Upload

func (s OSDBAPI) Upload(subtitlePath string, language Language, videoPath string) error

Upload uploads the subtitle to OpenSubtitles, for the given video

type SubDBAPI

type SubDBAPI struct {
	Name    string
	Aliases []string
}

SubDBAPI entry point

func SubDB

func SubDB() SubDBAPI

SubDB creates a new API for OpenSubtitles

func (SubDBAPI) Download

func (s SubDBAPI) Download(videoPath string, language Language) (subtitlePath string, err error)

Download downloads the SubDB subtitle from a video

func (SubDBAPI) GetAliases

func (s SubDBAPI) GetAliases() []string

GetAliases returns aliases to identify this API

func (SubDBAPI) GetName

func (s SubDBAPI) GetName() string

GetName returns the name of the api

func (SubDBAPI) Upload

func (s SubDBAPI) Upload(subtitlePath string, language Language, videoPath string) error

Upload uploads the subtitle to SubDB, for the given video

Jump to

Keyboard shortcuts

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