-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
82 lines (76 loc) · 1.32 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
72
73
74
75
76
77
78
79
80
81
82
package main
import (
"fmt"
"github.com/hr3lxphr6j/bililive-go/src/api"
"live-auto/src"
)
func main() {
src.LoadCfgRecorder()
cmd()
}
func cmd() {
for {
fmt.Println("1.add")
fmt.Println("2.remove")
fmt.Println("3.list")
fmt.Print("input:")
input := 0
_, err := fmt.Scanf("%d\n", &input)
if nil != err {
continue
}
switch input {
case 1:
add()
case 2:
remove()
case 3:
list()
default:
continue
}
}
}
func add() {
live_url := ""
fmt.Print("input url:")
_, err := fmt.Scanf("%s\n", &live_url)
if nil != err {
return
}
go func() {
recorder, err := src.NewRecorder(live_url, src.RecordConfig{
Loop: true,
AutoRemove: true,
EnableUploaders: []src.UploaderType{src.GDRIVE},
})
if nil != err {
fmt.Println(err)
return
}
err = src.GetIRecorderMngr().AddRecorder(recorder)
if nil != err {
fmt.Println(err)
return
}
recorder.Start()
}()
}
func remove() {
live_id := ""
fmt.Print("input live_id:")
_, err := fmt.Scanf("%s\n", &live_id)
if nil != err {
return
}
err = src.GetIRecorderMngr().RemoveRecorder(api.LiveId(live_id))
if nil != err {
fmt.Println(err.Error())
}
}
func list() {
list := src.GetIRecorderMngr().GetAllRecorder()
for _, rcd := range list {
fmt.Printf("%s %s\n", rcd.Live.GetLiveId(), rcd.Live.GetRawUrl())
}
}