-
Notifications
You must be signed in to change notification settings - Fork 84
/
config.go
99 lines (82 loc) · 1.87 KB
/
config.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Package config stores config type.
package config
import (
"os"
"os/exec"
"time"
"github.com/imdario/mergo"
)
const CoreConfigKey = "core_config"
var DefaultConfig = Config{
PortalUsername: "olive",
PortalPassword: "olive",
// core
LogDir: "",
SaveDir: "",
OutTmpl: `[{{ .StreamerName }}][{{ .RoomName }}][{{ now | date "2006-01-02 15-04-05"}}].flv`,
LogLevel: 5,
SnapRestSeconds: 15,
SplitRestSeconds: 60,
CommanderPoolSize: 1,
ParserMonitorRestSeconds: 300,
// tv
DouyinCookie: "",
KuaishouCookie: "",
PostCmdsRetryCount: 2,
}
type Config struct {
// portal
PortalUsername string
PortalPassword string
// core
LogDir string
SaveDir string
OutTmpl string
LogLevel uint32
SnapRestSeconds uint
SplitRestSeconds uint
CommanderPoolSize uint
ParserMonitorRestSeconds uint
PostCmdsRetryCount int
// tv
DouyinCookie string
KuaishouCookie string
// biliup
BiliupEnable bool
CookieFilepath string
Threads int64
MaxBytesPerSecond float64
}
func (cfg *Config) CheckAndFix() {
wd, _ := os.Getwd()
DefaultConfig.LogDir = wd
DefaultConfig.SaveDir = wd
mergo.Merge(cfg, DefaultConfig)
}
type ID string
type Bout interface {
IsConfigValid() bool
// show settings
GetID() ID
GetPlatform() string
GetRoomID() string
GetStreamerName() string
GetOutFilename() string
GetOutTmpl() string
GetSaveDir() string
GetParser() string
GetPostCmds() []*exec.Cmd
SatisfySplitRule(time.Time, string) bool
// show events
AddMonitor() error
RemoveMonitor() error
AddRecorder() error
RemoveRecorder() error
RestartRecorder()
// tv
Snap() error
StreamURL() (string, bool)
RoomName() (string, bool)
StreamerName() (string, bool)
SiteName() string
}