-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
62 lines (54 loc) · 1.13 KB
/
main.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
package main
import (
"bufio"
"encoding/json"
"fmt"
conn "imslp/connect"
"imslp/crawler"
"imslp/errcheck"
imdata "imslp/imslpData"
imparse "imslp/imslpParse"
"imslp/input"
"io/ioutil"
"log"
"os"
"strings"
)
func main() {
var (
in string
title string
errmsg = "imslp read error"
lists []input.List
id = 0
imData imdata.IMSLPInfo
music []imdata.IMSLPInfo
)
for {
log.Println("Enter the Composer and Title")
r := bufio.NewReader(os.Stdin)
in, _ = r.ReadString('\n')
s := strings.TrimSpace(in)
if s == "exit" {
break
}
lists = append(lists, input.Input(s, id))
id++
}
for _, imslp := range lists {
temp := strings.TrimSpace(imslp.URL) + "#tabScore2"
log.Println(temp)
res := conn.ConnectTLS(temp, errmsg)
imData = crawler.IMSLPScrape(res)
m := imparse.ParseInstr2(imData.Instr)
imData.Instrs = m
music = append(music, imData)
defer res.Body.Close()
}
data, _ := json.MarshalIndent(music, "", " ")
log.Println("Enter your json file's Title")
fmt.Scanln(&title)
log.Println("Complete")
errc := ioutil.WriteFile("./"+title+".json", data, 0)
errcheck.CheckError(errc, "")
}