-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
91 lines (78 loc) · 1.77 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
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
package main
import (
"ComicS/Model"
"ComicS/bili"
"flag"
"strings"
"time"
)
var (
oldMap map[int]Model.SingeResult
convOldMap = make(map[int]*Model.CompareResult, 30)
ontimeS string
pushString string
)
var debuglv int = 1
var sreacharea string
var onlyshowsale bool
var unixendtime int64 = -1
func main() {
area := flag.String("area", "gz", "place")
mode := flag.String("mode", "local", "mode")
isdebug := flag.Bool("d", false, "debug")
clear := flag.Bool("s", false, "only show saling")
endtimestring := flag.String("end", "no", "endtime format like 2024-08-23")
flag.Parse()
sreacharea = *area
onlyshowsale = *clear
if !*isdebug {
debuglv = 0
}
if *endtimestring != "no" {
t, _ := time.Parse("2006-01-02 15:04:05", *endtimestring)
unixendtime = t.Unix()
//fmt.Printf("\n flag data %s unix time:%d \n", *endtimestring, unixendtime)
}
if strings.ToLower(*mode) == "local" {
Show_info_local()
} else if strings.ToLower(*mode) == "file" {
SaveFile()
} else if strings.ToLower(*mode) == "daemon" {
DaemonRun()
} else if strings.ToLower(*mode) == "pic" {
genpic()
}
}
func Show_info_local() {
bc := bili.Get_client(sreacharea, onlyshowsale)
res, err := bc.GetAllResult()
if err != nil {
panic(err)
}
if debuglv == 1 {
res = bc.SortByTime(res, unixendtime)
bc.Show_result(res)
}
}
func SaveFile() {
bc := bili.Get_client(sreacharea, onlyshowsale)
res, err := bc.GetAllResult()
if err != nil {
panic(err)
}
res = bc.SortByTime(res, unixendtime)
bc.Save2file(res)
}
func DaemonRun() {
bc := bili.Get_client(sreacharea, onlyshowsale)
bc.DaemonMode()
}
func genpic() {
bc := bili.Get_client(sreacharea, onlyshowsale)
res, err := bc.GetAllResult()
if err != nil {
panic(err)
}
res = bc.SortByTime(res, unixendtime)
bc.Pic(res)
}