-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkumo.go
58 lines (48 loc) · 1.21 KB
/
kumo.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
package main
import (
"flag"
"log"
"os"
"./kumo"
)
func main() {
configName := flag.String("config", "config.json", "config file")
debug := flag.Bool("debug", false, "show debug statements")
debugFile := flag.String("debugFile", "", "write debug statments to debugFile")
quiet := flag.Bool("quiet", false, "hide the progress output")
par2 := flag.Bool("par2", false, "get only par2 files")
rm := flag.Bool("rm", false, "remove nzb file after download")
flag.Parse()
configFile, err := os.Open(*configName)
if err != nil {
log.Fatalf("Error opening config file: %v\n", err)
}
config, err := kumo.GetConfig(configFile)
if err != nil {
log.Fatalf("Error reading config: %v\n", err)
}
files := flag.Args()
if len(files) == 0 {
log.Fatalf("[MAIN] No files specified")
}
config.Debug = *debug
config.DebugFile = *debugFile
config.Quiet = *quiet
config.PAR2 = *par2
kumo := kumo.New(config)
for _, filename := range files {
if _, err := os.Stat(filename); err != nil {
log.Printf("\"%s\" does not exist.", filename)
continue
}
if kumo.Get(filename) != nil {
log.Printf("Error: %v", err)
}
if *rm {
os.Remove(filename)
}
}
if !config.Quiet {
println("⚑ All Done!")
}
}