Documentation ¶
Index ¶
- func ConvertToUTF8(b []byte) string
- func LooksLikeTextSubtitle(filename string) bool
- func SubDbHashFromFile(f *os.File) (string, error)
- func TimeSRT(t time.Time) string
- func TimeVTT(t time.Time) string
- type Caption
- type SubFinder
- type Subtitle
- func NewFromCCDBCapture(s string) (res Subtitle, err error)
- func NewFromDCSub(s string) (res Subtitle, err error)
- func NewFromSRT(s string) (res Subtitle, err error)
- func NewFromSSA(s string) (res Subtitle, err error)
- func NewFromVTT(s string) (res Subtitle, err error)
- func Parse(b []byte) (Subtitle, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LooksLikeTextSubtitle ¶
LooksLikeTextSubtitle returns true i byte stream seems to be of a recognized format
func SubDbHashFromFile ¶
SubDbHashFromFile returns a checksum in hex-string representation conforming to http://trac.opensubtitles.org/projects/opensubtitles/wiki/HashSourceCodes
Types ¶
type SubFinder ¶
SubFinder represents a video being queried for subtitles
func NewSubFinder ¶
NewSubFinder returns a new SubFinder
type Subtitle ¶
type Subtitle struct {
Captions []Caption
}
Subtitle holds a parsed subtitle
func NewFromCCDBCapture ¶
NewFromCCDBCapture parses a ccdb capture text into []Caption, assumes s is a clean utf8 string
func NewFromDCSub ¶
NewFromDCSub parses a dcsubtitle xml sub, assumes s is a clean utf8 string
func NewFromSRT ¶
NewFromSRT parses a .srt text into Subtitle, assumes s is a clean utf8 string
Example ¶
in := "1\n" + "00:00:04,630 --> 00:00:06,018\n" + "Go ninja!\n" + "\n" + "1\n" + "00:01:09,630 --> 00:01:11,005\n" + "No ninja!\n" res, _ := NewFromSRT(in)
Output: WEBVTT 00:04.630 --> 00:06.018 Go ninja! 01:09.630 --> 01:11.005 No ninja!
func NewFromSSA ¶
NewFromSSA parses a .ssa text into []Caption, assumes s is a clean utf8 string
func NewFromVTT ¶
NewFromVTT parses a .vtt text into Subtitle, assumes s is a clean utf8 string
func (*Subtitle) AsVTT ¶
AsVTT renders the sub in WebVTT format https://en.wikipedia.org/wiki/WebVTT
func (*Subtitle) FilterCaptions ¶
FilterCaptions pass the captions through a filter function
func (*Subtitle) ResyncSubs ¶
ResyncSubs adjust text timing by `sync` milliseconds