Skip to content

Commit 94f7507

Browse files
committed
renamed package from subber to subtitles
1 parent e78a3ae commit 94f7507

20 files changed

+40
-21
lines changed

caps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package subber
1+
package subtitles
22

33
import (
44
"log"

caps_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package subber
1+
package subtitles
22

33
import (
44
"testing"

caption.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package subber
1+
package subtitles
22

33
import "time"
44

caption_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package subber
1+
package subtitles
22

33
import (
44
"testing"

cleaner.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
package subber
1+
package subtitles
22

33
import (
4+
"fmt"
45
"log"
56
"strings"
7+
"time"
68
)
79

810
// CleanupSub parses .srt or .ssa, performs cleanup and renders to a .srt, returning a string. caller is responsible for passing UTF8 string
9-
func CleanupSub(utf8 string, filterName string, keepAds bool) (string, error) {
11+
func CleanupSub(utf8 string, filterName string, keepAds bool, sync int) (string, error) {
1012

1113
var captions []caption
1214

@@ -21,13 +23,30 @@ func CleanupSub(utf8 string, filterName string, keepAds bool) (string, error) {
2123
captions = removeAds(captions)
2224
}
2325

26+
if sync != 0 {
27+
captions = resyncSubs(captions, sync)
28+
}
29+
2430
captions = filterSubs(captions, filterName)
2531

2632
out := renderSrt(captions)
2733

2834
return out, nil
2935
}
3036

37+
func resyncSubs(subs []caption, sync int) []caption {
38+
39+
// var res []caption
40+
fmt.Printf("resyncing with %d\n", sync)
41+
42+
for i := range subs {
43+
subs[i].Start = subs[i].Start.Add(time.Duration(sync) * time.Millisecond)
44+
subs[i].End = subs[i].End.Add(time.Duration(sync) * time.Millisecond)
45+
}
46+
47+
return subs
48+
}
49+
3150
// RemoveAds removes advertisement from the subtitles
3251
func removeAds(subs []caption) []caption {
3352

cleaner_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package subber
1+
package subtitles
22

33
import (
44
"testing"

encoding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package subber
1+
package subtitles
22

33
import (
44
"bytes"

encoding_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package subber
1+
package subtitles
22

33
import (
44
"testing"

filter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package subber
1+
package subtitles
22

33
import (
44
"fmt"

helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package subber
1+
package subtitles
22

33
import "os"
44

0 commit comments

Comments
 (0)