-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathupdate.go
72 lines (59 loc) · 1.45 KB
/
update.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
package main
import (
"fmt"
"strings"
"github.com/ma6254/FictionDown/site"
"github.com/ma6254/FictionDown/store"
"github.com/urfave/cli"
)
var update = cli.Command{
Name: "update",
Aliases: []string{"u"},
Usage: "检查更新信息",
Action: func(c *cli.Context) error {
if err := initLoadStore(c); err != nil {
return err
}
updateStore, err := site.BookInfo(chapter.BookURL)
if err != nil {
return nil
}
chapterLen := 0
for _, v := range updateStore.Volumes {
chapterLen += len(v.Chapters)
}
oldChapterLen := 0
for _, v := range chapter.Volumes {
oldChapterLen += len(v.Chapters)
}
fmt.Printf("书名: %#v\n", chapter.BookName)
fmt.Printf("作者: %#v\n", chapter.Author)
fmt.Printf("封面: %s\n", chapter.CoverURL)
fmt.Printf("简介: \n\t%v\n", strings.Replace(chapter.Description, "\n", "\n\t", -1))
fmt.Printf("章节数: \n")
for k, v := range chapter.Volumes {
var VIP string
if v.IsVIP {
VIP = "收费"
} else {
VIP = "免费"
}
fmt.Printf("\t%s(%s) %d章 => ", v.Name, VIP, len(v.Chapters))
for kk, vv := range updateStore.Volumes {
if (vv.Name == v.Name) && (kk == k) {
fmt.Printf("%d章 ", len(vv.Chapters))
}
}
fmt.Println()
}
diffVol := []store.Volume{}
copy(diffVol, updateStore.Volumes)
for k, v := range chapter.Volumes {
for kk, vv := range updateStore.Volumes {
if (vv.Name == v.Name) && (kk == k) {
}
}
}
return nil
},
}