forked from martinlindhe/subtitles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleaner.go
106 lines (100 loc) · 3.49 KB
/
cleaner.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package subtitles
import (
"strings"
"time"
)
// ResyncSubs adjust text timing by `sync` milliseconds
func (subtitle *Subtitle) ResyncSubs(sync int) {
// log.Printf("resyncing with %d\n", sync)
for i := range subtitle.Captions {
subtitle.Captions[i].Start = subtitle.Captions[i].Start.
Add(time.Duration(sync) * time.Millisecond)
subtitle.Captions[i].End = subtitle.Captions[i].End.
Add(time.Duration(sync) * time.Millisecond)
}
}
var (
advertisements = []string{
// english:
"captions paid for by",
"english subtitles",
"subtitles:", "subtitles by",
"subtitles downloaded",
"captioning by", "captions by",
"transcript :", "transcript:", "transcript by",
"sync, corrected", "synced and corrected",
"sync and corrected", "sync & corrections",
"sync and corrections",
"traduction:", "transcript par",
"corrections by",
"sync by n17t01",
"sync,", "synchro :", "synchro:", "synced by", "synchronized by",
"synchronization by", "synchronisation:",
"resynchronization:",
"resync:", "resynchro", "resync by",
"translation by",
"encoded by",
"web-dl",
"subscene",
"seriessub",
"addic7ed", "addicted.com", "vaioholics",
"sdimedia", "sdi media",
"allsubs.org", "hdbits.org", "bierdopje.com", "subcentral", "mkvcage",
"cssubs", "tvsub", "uksubtitles",
"ragbear.com", "ydy.com", "yyets.net", "indivx.net", "sub-way.fr", "blogspot",
"forom.com", "forom. com", "facebook.com", "hdvietnam.com", "sapo.pt", "softhome.net",
"americascardroom.com",
"@gmail.com", "@hotmail.com", "@hotmail.fr",
"napisy.org", "1000fr.com",
"opensubtitles", "open subtitles", "s u b t i t l e",
"sous-titres.eu", "300mbfilms.com", "put.io", "subtitulos.es", "osdb.link", "300mbunited",
"simail.si", "sf.net", "vitac.com", "rapidpremium", "psarips",
"yify-torrents", "yify torrents",
"thepiratebay", "anoxmous", "verdikt", "la fisher team", "red bee media",
"mkv player", "best watched using", "advertise your product", "remove all ads",
"memoryonsmells", "1st-booking",
":[gwc]:", "ripped by", "ripped with subrip", "titra film",
// swedish:
"swedish subtitles", "svenska undertexter", "internationella undertexter",
"svensktextning", "(c) sveriges televisionit", "sveriges television ab",
"undertexter.se", "undertexter. se", "swesub.nu", "divxsweden",
"undertext av", "översatt av", "översättning:", "översättning av", "rättad av",
"synkad av", "synkat av", "synk:", "synkning:", "redigerad av", "textning:",
"svensk text", "text:", "omsynk:", "omsynkad",
"transkribering:", "piratpartiet.se",
"korrektur:", "korrekturläst", "texter på nätet", "text hämtad från",
"din filmsajt på nätet", "din största filmsajt på nätet",
"alltid nya texter",
"senaste undertexter på",
"programtextning", "översättargrupp",
"mediatextgruppen", "visiontext", "scandinavian text service",
"jhs International", "svensk medietext",
// french:
"relecture et corrections finales:",
}
)
// RemoveAds removes advertisement from the subtitles
func (subtitle *Subtitle) RemoveAds() *Subtitle {
seq := 1
res := []Caption{}
for _ /* orgSeq */, sub := range subtitle.Captions {
isAd := false
for _, line := range sub.Text {
x := strings.ToLower(line)
for _, adLine := range advertisements {
if !isAd && strings.Contains(x, adLine) {
isAd = true
// log.Println("[ads]", (orgSeq + 1), sub.Text, "matched", adLine)
break
}
}
}
if !isAd {
sub.Seq = seq
res = append(res, sub)
seq++
}
}
subtitle.Captions = res
return subtitle
}