Skip to content

Commit

Permalink
renamed package from subber to subtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlindhe committed Jan 4, 2016
1 parent e78a3ae commit 94f7507
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 21 deletions.
2 changes: 1 addition & 1 deletion caps.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"log"
Expand Down
2 changes: 1 addition & 1 deletion caps_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion caption.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import "time"

Expand Down
2 changes: 1 addition & 1 deletion caption_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"testing"
Expand Down
23 changes: 21 additions & 2 deletions cleaner.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package subber
package subtitles

import (
"fmt"
"log"
"strings"
"time"
)

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

var captions []caption

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

if sync != 0 {
captions = resyncSubs(captions, sync)
}

captions = filterSubs(captions, filterName)

out := renderSrt(captions)

return out, nil
}

func resyncSubs(subs []caption, sync int) []caption {

// var res []caption
fmt.Printf("resyncing with %d\n", sync)

for i := range subs {
subs[i].Start = subs[i].Start.Add(time.Duration(sync) * time.Millisecond)
subs[i].End = subs[i].End.Add(time.Duration(sync) * time.Millisecond)
}

return subs
}

// RemoveAds removes advertisement from the subtitles
func removeAds(subs []caption) []caption {

Expand Down
2 changes: 1 addition & 1 deletion cleaner_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion encoding.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion encoding_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion filter.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion helpers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import "os"

Expand Down
2 changes: 1 addition & 1 deletion html.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"log"
Expand Down
2 changes: 1 addition & 1 deletion html_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

// parse tries to parse a subtitle from the data stream
func parse(b []byte) []caption {
Expand Down
2 changes: 1 addition & 1 deletion srt.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion srt_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion ssa.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion ssa_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion testextras.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion thesubdb.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"crypto/md5"
Expand Down
2 changes: 1 addition & 1 deletion thesubdb_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subber
package subtitles

import (
"os"
Expand Down

0 comments on commit 94f7507

Please sign in to comment.