summaryrefslogtreecommitdiff
path: root/recording/config.go
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-09-08 00:31:26 +0800
committerKeuin <[email protected]>2022-09-08 00:31:26 +0800
commita720c2c16b442b668db465fbbc70740cfc7ddee4 (patch)
treeaac1ba37e4a19c3e9c34f70e9297b0a9e3803db6 /recording/config.go
parentd00c97e9dbfb59672ced042af8a6e849efab98cc (diff)
Load config from file or cli.
Diffstat (limited to 'recording/config.go')
-rw-r--r--recording/config.go29
1 files changed, 26 insertions, 3 deletions
diff --git a/recording/config.go b/recording/config.go
index 1a24508..bcd5755 100644
--- a/recording/config.go
+++ b/recording/config.go
@@ -1,6 +1,9 @@
package recording
-import "bilibili-livestream-archiver/common"
+import (
+ "bilibili-livestream-archiver/common"
+ "fmt"
+)
type TaskConfig struct {
RoomId common.RoomId `mapstructure:"room_id"`
@@ -15,6 +18,26 @@ type TransportConfig struct {
}
type DownloadConfig struct {
- SaveDirectory string `mapstructure:"save_directory"`
- FileNameTemplate string `mapstructure:"file_name_template"`
+ SaveDirectory string `mapstructure:"save_directory"`
+}
+
+func DefaultTransportConfig() TransportConfig {
+ return TransportConfig{
+ SocketTimeoutSeconds: 10,
+ RetryIntervalSeconds: 2,
+ MaxRetryTimes: 5,
+ }
+}
+
+func (t TaskConfig) String() string {
+ return fmt.Sprintf("room: %v, %v, %v", t.RoomId, t.Transport.String(), t.Download.String())
+}
+
+func (t TransportConfig) String() string {
+ return fmt.Sprintf("socket timeout: %vs, retry interval: %vs, max retry times: %v",
+ t.SocketTimeoutSeconds, t.RetryIntervalSeconds, t.MaxRetryTimes)
+}
+
+func (d DownloadConfig) String() string {
+ return fmt.Sprintf("save directory: %v", d.SaveDirectory)
}