/
main.go
49 lines (46 loc) · 849 Bytes
/
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
package main
import (
"flag"
"fmt"
"os"
"strings"
)
func showList(c compositions) {
var s string
for i, song := range c {
if (i+1) != len(c) && (i+1)%p.chank == 0 {
fmt.Printf("%d. %s", i+1, song)
_, _ = fmt.Scanln(&s)
continue
}
fmt.Printf("%d. %s\n", i+1, song)
}
}
func main() {
flag.Parse()
if len(os.Args) == 1 {
show = true
}
search := strings.Join(flag.Args(), "+")
var songsList []int
if download != "-1" {
songsList = getRange(download)
}
path := p.path
if search == "" {
path = ""
}
addr := createAddr(p.scheme, p.host, path, search, 1)
body := getSiteBody(addr)
songs := getComposition(body, p.list)
if len(songs) == 0 {
fmt.Println("Композиций не найдено.")
os.Exit(1)
}
if show {
showList(songs)
}
if download != "-1" {
saveCompositions(songs, songsList)
}
}