-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
55 lines (49 loc) · 1.11 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
package main
import (
"fengqi/qbittorrent-tool/config"
"fengqi/qbittorrent-tool/qbittorrent"
"fengqi/qbittorrent-tool/tool"
"flag"
"fmt"
"log"
"strconv"
)
func main() {
configFile := flag.String("c", "./config.json", "config file path")
flag.Parse()
c, err := config.LoadConfig(*configFile)
if err != nil {
fmt.Printf("[ERR] load config err: %v\n", err)
return
}
if err = qbittorrent.Init(c); err != nil {
fmt.Printf("[ERR] login to qbittorrent err %v\n", err)
return
}
offset := 0
limit := 1000
for {
params := map[string]string{
"filter": "all",
"sort": "added_on",
"limit": strconv.Itoa(limit),
"offset": strconv.Itoa(offset),
}
torrentList, err := qbittorrent.Api.GetTorrentList(params)
if err != nil {
log.Printf("[ERR] get torrent list err %v\n", err)
return
}
log.Printf("[INFO] get torrent list count: %d\n", len(torrentList))
for _, torrent := range torrentList {
tool.AutoCategory(c, torrent)
tool.DomainTag(c, torrent)
tool.SeedingLimits(c, torrent)
tool.StatusTag(c, torrent)
}
if len(torrentList) < limit {
break
}
offset += limit
}
}