-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconvert_zawgyi.go
47 lines (41 loc) · 956 Bytes
/
convert_zawgyi.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
package main
import (
"bufio"
"fmt"
"github.com/Rabbit-Converter/Rabbit-Go"
"io/ioutil"
"os"
)
func main() {
const ytidsFilename = "zawgyi_ytids.dat"
const subFormat = "vtt"
var subs string
var ytids []string
fytids, err := os.Open(ytidsFilename)
if err != nil {
panic(err)
}
defer fytids.Close()
fileScanner := bufio.NewScanner(fytids)
fileScanner.Split(bufio.ScanLines)
for fileScanner.Scan() {
ytids = append(ytids, fileScanner.Text())
}
for _, ytid := range ytids {
fname_in := "subs_original/" + ytid + ".my." + subFormat
fname_out := "subs_converted/" + ytid + ".my." + subFormat
data, err := ioutil.ReadFile(fname_in)
if err != nil {
fmt.Printf("%s\tNOT FOUND\n", ytid)
continue
}
subs = string(data)
subs_uni := rabbit.Zg2uni(subs)
data = []byte(subs_uni)
err = ioutil.WriteFile(fname_out, data, 0644)
if err != nil {
fmt.Printf("Could not write to file %s\n", fname_out)
return
}
}
}