-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework to only export a few functions
- Loading branch information
1 parent
c230a8e
commit 695f068
Showing
32 changed files
with
417 additions
and
472 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
test: | ||
go test -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package subber | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFilterCapitalization(t *testing.T) { | ||
|
||
var in = []caption{ | ||
{ | ||
Seq: 1, | ||
Start: makeTime(0, 0, 4, 630), | ||
End: makeTime(0, 0, 6, 18), | ||
Text: []string{"GO NINJA!", "NINJA GO!"}, | ||
}, | ||
} | ||
|
||
var expected = []caption{ | ||
{ | ||
1, | ||
makeTime(0, 0, 4, 630), | ||
makeTime(0, 0, 6, 18), | ||
[]string{"Go ninja!", "Ninja go!"}, | ||
}, | ||
} | ||
|
||
assert.Equal(t, expected, filterCapitalization(in)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package subber | ||
|
||
import "time" | ||
|
||
// caption represents one subtitle block | ||
type caption struct { | ||
Seq int | ||
Start time.Time | ||
End time.Time | ||
Text []string | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package subber | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRenderTime(t *testing.T) { | ||
|
||
cap := caption{ | ||
1, | ||
makeTime(18, 40, 22, 110), | ||
makeTime(18, 41, 20, 123), | ||
[]string{"<i>Go ninja!</i>"}, | ||
} | ||
|
||
assert.Equal(t, "18:40:22,110 --> 18:41:20,123", cap.srtTime()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package subber | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRemoveAds(t *testing.T) { | ||
|
||
var in = []caption{ | ||
{ | ||
1, | ||
makeTime(0, 0, 4, 630), | ||
makeTime(0, 0, 6, 18), | ||
[]string{"Go ninja!"}, | ||
}, | ||
{ | ||
2, | ||
makeTime(0, 1, 9, 630), | ||
makeTime(0, 1, 11, 005), | ||
[]string{"Subtitles By MrCool"}, | ||
}, | ||
{ | ||
3, | ||
makeTime(0, 1, 9, 630), | ||
makeTime(0, 1, 11, 005), | ||
[]string{"No ninja!"}, | ||
}, | ||
} | ||
|
||
var expected = []caption{ | ||
{ | ||
1, | ||
makeTime(0, 0, 4, 630), | ||
makeTime(0, 0, 6, 18), | ||
[]string{"Go ninja!"}, | ||
}, | ||
{ | ||
2, | ||
makeTime(0, 1, 9, 630), | ||
makeTime(0, 1, 11, 005), | ||
[]string{"No ninja!"}, | ||
}, | ||
} | ||
|
||
assert.Equal(t, expected, removeAds(in)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package txtformat | ||
package subber | ||
|
||
import ( | ||
"testing" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package subber | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// filterSubs pass the captions through a filter function | ||
func filterSubs(captions []caption, filter string) []caption { | ||
|
||
if filter == "caps" { | ||
return filterCapitalization(captions) | ||
} | ||
if filter == "html" { | ||
return filterHTML(captions) | ||
} | ||
if filter != "none" { | ||
fmt.Printf("Unrecognized filter name: %s\n", filter) | ||
} | ||
|
||
return captions | ||
} |
Oops, something went wrong.