forked from zsakvo/dhbooker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (36 loc) · 1.01 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
package main
import (
"flag"
"fmt"
"strconv"
)
func main() {
getConfig()
path = getPathSettings()
fmt.Println("正在清理临时目录")
destoryTemp()
fmt.Println("正在检查凭证")
token := getToken()
if len(token) == 0 {
fmt.Println("无凭证,尝试使用用户密码登入")
account := getAccountSettings()
loginByPass(account)
} else {
fmt.Println("尝试使用上次凭证登入")
localToken := getSection("token")["token"]
loginByToken(localToken)
}
flag.StringVar(&downloadType, "t", "txt", "下载类型,可选 txt 或 epub")
flag.StringVar(&bookID, "b", "", "bookID,请在对应网页 url 中获取")
flag.Parse()
getBookInfo()
bookTmpPath = path.tmp + "/" + bookName + "/"
fmt.Println("《" + bookName + "》")
rolls, rollNum := getBookRolls()
chapterIDs, chapterNum := getChapters(rolls)
bookChapterNum = chapterNum
fmt.Println("共" + strconv.Itoa(rollNum) + "卷," + strconv.Itoa(chapterNum) + "章")
downloadChapters(chapterIDs)
destoryTemp()
fmt.Print("\n下载完毕")
}