Skip to content

Commit

Permalink
Cleaning repo, linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin ROCHE committed Apr 14, 2022
1 parent 6ae30f7 commit 798bafc
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 295 deletions.
5 changes: 0 additions & 5 deletions .gitignore

This file was deleted.

15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

39 changes: 1 addition & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
[![GoReportCard](http://goreportcard.com/badge/github.com/asticode/go-astisub)](http://goreportcard.com/report/github.com/asticode/go-astisub)
[![GoDoc](https://godoc.org/github.com/asticode/go-astisub?status.svg)](https://godoc.org/github.com/asticode/go-astisub)
[![Travis](https://travis-ci.com/asticode/go-astisub.svg?branch=master)](https://travis-ci.com/asticode/go-astisub#)
[![Coveralls](https://coveralls.io/repos/github/asticode/go-astisub/badge.svg?branch=master)](https://coveralls.io/github/asticode/go-astisub)

This is a Golang library to manipulate subtitles.

It allows you to manipulate `srt`, `stl`, `ttml`, `ssa/ass`, `webvtt` and `teletext` files for now.
Expand All @@ -13,11 +8,7 @@ Available operations are `parsing`, `writing`, `syncing`, `fragmenting`, `unfrag

To install the library:

go get github.com/asticode/go-astisub

To install the CLI:

go install github.com/asticode/go-astisub/astisub
go get github.com/molotovtv/go-astisub

# Using the library in your code

Expand Down Expand Up @@ -49,34 +40,6 @@ var buf = &bytes.Buffer{}
s2.WriteToTTML(buf)
```

# Using the CLI

If **astisub** has been installed properly you can:

- convert any type of subtitle to any other type of subtitle:

astisub convert -i example.srt -o example.ttml

- fragment any type of subtitle:

astisub fragment -i example.srt -f 2s -o example.out.srt

- merge any type of subtitle into any other type of subtitle:

astisub merge -i example.srt -i example.ttml -o example.out.srt

- optimize any type of subtitle:

astisub optimize -i example.srt -o example.out.srt

- unfragment any type of subtitle:

astisub unfragment -i example.srt -o example.out.srt

- sync any type of subtitle:

astisub sync -i example.srt -s "-2s" -o example.out.srt

# Features and roadmap

- [x] parsing
Expand Down
114 changes: 0 additions & 114 deletions astisub/main.go

This file was deleted.

20 changes: 13 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
module github.com/asticode/go-astisub
module github.com/molotovtv/go-astisub

go 1.13
go 1.18

require (
github.com/asticode/go-astikit v0.20.0
github.com/asticode/go-astits v1.8.0
github.com/stretchr/testify v1.4.0
golang.org/x/net v0.0.0-20200904194848-62affa334b73
golang.org/x/text v0.3.2
github.com/asticode/go-astikit v0.29.1
github.com/asticode/go-astits v1.10.0
github.com/stretchr/testify v1.7.1
golang.org/x/net v0.0.0-20220412020605-290c469a71a5
golang.org/x/text v0.3.7
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
29 changes: 12 additions & 17 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
github.com/asticode/go-astikit v0.20.0 h1:+7N+J4E4lWx2QOkRdOf6DafWJMv6O4RRfgClwQokrH8=
github.com/asticode/go-astikit v0.20.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0=
github.com/asticode/go-astits v1.8.0 h1:rf6aiiGn/QhlFjNON1n5plqF3Fs025XLUwiQ0NB6oZg=
github.com/asticode/go-astits v1.8.0/go.mod h1:DkOWmBNQpnr9mv24KfZjq4JawCFX1FCqjLVGvO0DygQ=
github.com/asticode/go-astikit v0.29.1 h1:w27sLYXK84mDwArf/Vw1BiD5dfD5PBDB+iHoIcpYq0w=
github.com/asticode/go-astikit v0.29.1/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0=
github.com/asticode/go-astits v1.10.0 h1:ixKsRl84nWtjgHWcWKTDkUHNQ4kxbf9nKmjuSCninCU=
github.com/asticode/go-astits v1.10.0/go.mod h1:DkOWmBNQpnr9mv24KfZjq4JawCFX1FCqjLVGvO0DygQ=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pkg/profile v1.4.0/go.mod h1:NWz/XGvpEW1FyYQ7fCx4dqYBLlfTcE+A9FLAkNKqjFE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 h1:bRb386wvrE+oBNdF1d/Xh9mQrfQ4ecYhW5qJ5GvTGT4=
golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion srt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"testing"

"github.com/asticode/go-astisub"
"github.com/molotovtv/go-astisub"
"github.com/stretchr/testify/assert"
)

Expand Down
49 changes: 1 addition & 48 deletions ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"fmt"
"io"
"log"
"regexp"
"sort"
"strconv"
Expand All @@ -18,36 +17,9 @@ import (
// http://moodub.free.fr/video/ass-specs.doc
// https://en.wikipedia.org/wiki/SubStation_Alpha

// SSA alignment
const (
ssaAlignmentCentered = 2
ssaAlignmentLeft = 1
ssaAlignmentLeftJustifiedTopTitle = 5
ssaAlignmentMidTitle = 8
ssaAlignmentRight = 3
ssaAlignmentTopTitle = 4
)

// SSA border styles
const (
ssaBorderStyleOpaqueBox = 3
ssaBorderStyleOutlineAndDropShadow = 1
)

// SSA collisions
const (
ssaCollisionsNormal = "Normal"
ssaCollisionsReverse = "Reverse"
)

// SSA event categories
const (
ssaEventCategoryCommand = "Command"
ssaEventCategoryComment = "Comment"
ssaEventCategoryDialogue = "Dialogue"
ssaEventCategoryMovie = "Movie"
ssaEventCategoryPicture = "Picture"
ssaEventCategorySound = "Sound"
)

// SSA event format names
Expand Down Expand Up @@ -121,20 +93,12 @@ const (
ssaStyleFormatNameUnderline = "Underline"
)

// SSA wrap style
const (
ssaWrapStyleEndOfLineWordWrapping = "1"
ssaWrapStyleNoWordWrapping = "2"
ssaWrapStyleSmartWrapping = "0"
ssaWrapStyleSmartWrappingWithLowerLinesGettingWider = "3"
)

// SSA regexp
var ssaRegexpEffect = regexp.MustCompile(`\{[^\{]+\}`)

// ReadFromSSA parses an .ssa content
func ReadFromSSA(i io.Reader) (o *Subtitles, err error) {
o, err = ReadFromSSAWithOptions(i, defaultSSAOptions())
o, err = ReadFromSSAWithOptions(i, SSAOptions{})
return o, err
}

Expand Down Expand Up @@ -1284,14 +1248,3 @@ type SSAOptions struct {
OnUnknownSectionName func(name string)
OnInvalidLine func(line string)
}

func defaultSSAOptions() SSAOptions {
return SSAOptions{
OnUnknownSectionName: func(name string) {
log.Printf("astisub: unknown section: %s", name)
},
OnInvalidLine: func(line string) {
log.Printf("astisub: not understood: '%s', ignoring", line)
},
}
}
2 changes: 1 addition & 1 deletion ssa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/asticode/go-astikit"
"github.com/asticode/go-astisub"
"github.com/molotovtv/go-astisub"
"github.com/stretchr/testify/assert"
)

Expand Down
Loading

0 comments on commit 798bafc

Please sign in to comment.