-
Notifications
You must be signed in to change notification settings - Fork 0
/
single.go
44 lines (38 loc) · 803 Bytes
/
single.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
package pixiv
type single struct {
pixiv
workId chan string
}
// Single Constructor of single picture.
//
// workId -the id of the single picture.
func Single(workId string) *single {
s := new(single)
s.rname = "single"
s.log = myLog.WithField("place", "single")
s.savePath = globalConfig.GetString("download.single.path")
s.num = 1
s.workId = make(chan string, 1)
s.defaultSingleDir()
go func() {
s.workId <- workId
close(s.workId)
}()
return s
}
// Name Set single dir name.
//
// Default is single
func (s *single) Name(dirName string) *single {
s.fileDir = dirName
return s
}
func (s *single) Download() {
s.downLoadImg(s.getImgUrls(s.workId))
}
func (s *single) Upload() {
s.upLoadImg(s.getImgUrls(s.workId))
}
func (s *single) defaultSingleDir() {
s.fileDir = "single"
}