Skip to content

Commit

Permalink
subtitle.RemoveAds(): add verbose argument
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlindhe committed Oct 21, 2024
1 parent 0d7ca24 commit a09d8c9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ var (
)

// RemoveAds removes advertisement from the subtitles
func (subtitle *Subtitle) RemoveAds(outputPrefix string) *Subtitle {
func (subtitle *Subtitle) RemoveAds(outputPrefix string, verbose bool) *Subtitle {

info := color.New(color.FgGreen, color.BgBlack).SprintFunc()
orange := color.New(color.FgBlack, color.BgHiYellow).SprintFunc()
Expand All @@ -120,7 +120,9 @@ func (subtitle *Subtitle) RemoveAds(outputPrefix string) *Subtitle {
for _, adLine := range advertisements {
if !isAd && strings.Contains(block, adLine) {
isAd = true
fmt.Printf("%s [ads] %d %s matched (%s)\n", info(outputPrefix), (orgSeq + 1), orange(sub.Text), adLine)
if verbose {
fmt.Printf("%s [ads] %d %s matched (%s)\n", info(outputPrefix), (orgSeq + 1), orange(sub.Text), adLine)
}
break
}
}
Expand Down
2 changes: 1 addition & 1 deletion cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ func TestRemoveAds(t *testing.T) {
makeTime(0, 1, 11, 005),
[]string{"No ninja!"},
}}}
assert.Equal(t, &expected, in.RemoveAds(""))
assert.Equal(t, &expected, in.RemoveAds("", false))
}
2 changes: 1 addition & 1 deletion cmd/subber/subber.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func cleanupSub(data []byte, filterName string, keepAds bool, sync int, cleanerO
return "", err
}
if !keepAds {
subtitle.RemoveAds(cleanerOutputPrefix)
subtitle.RemoveAds(cleanerOutputPrefix, true)
}
if sync != 0 {
subtitle.ResyncSubs(sync)
Expand Down

0 comments on commit a09d8c9

Please sign in to comment.