-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
54 lines (50 loc) · 1.35 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
package main
import (
"os"
"strconv"
)
func setup() {
println("Setup...")
// Check if directories exist
if _, err := os.Stat("temp"); os.IsNotExist(err) {
os.Mkdir("temp", os.ModePerm)
}
if _, err := os.Stat("out"); os.IsNotExist(err) {
os.Mkdir("out", os.ModePerm)
}
if _, err := os.Stat("bunkr"); os.IsNotExist(err) {
os.Mkdir("bunkr", os.ModePerm)
}
print("Setup done.")
}
func main() {
setup() // Create directories if not exist
if len(os.Args) == 2 {
println("Single argument mode: A single nhentai or bunkr album will be downloaded.")
arg := os.Args[1]
// decide if it is a nhentai or bunkr album, if its only numbers, its nhentai
if _, err := strconv.Atoi(arg); err == nil {
hentai := getByID(arg)
path := DownloadHentai(hentai, "temp")
CompilePdf(path, "out")
} else {
album := GetBunkrAlbum(arg)
DownloadBunkrAlbum(album, "bunkr")
}
return
}
println("Batch mode: nhentai and bunkr albums will be downloaded from the links in the files.")
// Download bunkr albums
links := ReadBunkrDownloadFile("bunkrlinks.txt")
for _, link := range links {
album := GetBunkrAlbum(link)
DownloadBunkrAlbum(album, "bunkr")
}
// Download nhentai albums
links = ReadHentaiDownloadFile("hentailinks.txt")
for _, link := range links {
hentai := getByID(link)
path := DownloadHentai(hentai, "temp")
CompilePdf(path, "out")
}
}