-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
71 lines (61 loc) · 2.19 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"aria2-ext/dao"
"aria2-ext/job"
plug "aria2-ext/plugin"
"fmt"
"github.com/robfig/cron"
"os"
"os/signal"
"strings"
"syscall"
)
const (
Git = "https://gitee.com/Cikaros/aria2-ext"
Author = "Cikaros"
Blog = "https://cikaros.gitee.io"
Version = "v0.3.0"
BuildTime = "2023/04/03 12:00"
)
const Banner = `
----------------------------------------------------------------
█████╗ ██████╗ ██╗ █████╗ ██████╗ ███████╗██╗ ██╗████████╗
██╔══██╗██╔══██╗██║██╔══██╗╚════██╗ ██╔════╝╚██╗██╔╝╚══██╔══╝
███████║██████╔╝██║███████║ █████╔╝ █████╗ ╚███╔╝ ██║
██╔══██║██╔══██╗██║██╔══██║██╔═══╝ ██╔══╝ ██╔██╗ ██║
██║ ██║██║ ██║██║██║ ██║███████╗ ███████╗██╔╝ ██╗ ██║
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝╚══════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝
%s
Copyright (c) %s 2023-2024 <%s>
Version: %s | Build Time: %s
----------------------------------------------------------------
`
var startup = strings.ToLower(os.Getenv("ARIA2_STARTUP")) == "true"
func banner(jobs []dao.Rss) {
fmt.Printf(Banner, Git, Author, Blog, Version, BuildTime)
for _, rss := range jobs {
rss.Info()
}
fmt.Println("----------------------------------------------------------------")
}
func main() {
var timer = cron.New() //定时器
var rsses []dao.Rss
dao.Conn.Find(&rsses) //加载订阅任务
banner(rsses)
plug.Init()
for _, rss := range rsses {
parse := job.Parse{Rss: rss}
parse.Load(timer)
}
job.Init()
timer.Start()
if startup {
timer.Run()
}
quit := make(chan os.Signal)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
timer.Stop()
job.Destroy()
}