summaryrefslogtreecommitdiff
path: root/recording
diff options
context:
space:
mode:
Diffstat (limited to 'recording')
-rw-r--r--recording/runner.go7
-rw-r--r--recording/task.go16
2 files changed, 19 insertions, 4 deletions
diff --git a/recording/runner.go b/recording/runner.go
index 9be78c9..7bf3790 100644
--- a/recording/runner.go
+++ b/recording/runner.go
@@ -175,7 +175,9 @@ func tryRunTask(t *RunningTask) error {
var err error
run := true
for run {
- err = record(t.ctx, bi, &t.TaskConfig, t.logger)
+ err = record(t.ctx, bi, &t.TaskConfig, t.logger, func(resp types.RoomProfileResponse) {
+ t.roomTitle.Store(&resp.Data.Title)
+ })
if err == nil {
// live is ended
t.logger.Info("The live is ended. Restarting current task...")
@@ -247,6 +249,7 @@ func record(
bi *bilibili.Bilibili,
task *TaskConfig,
logger logging.Logger,
+ profileConsumer func(types.RoomProfileResponse),
) error {
logger.Info("Getting room profile...")
@@ -265,6 +268,8 @@ func record(
return errs.NewError(errs.GetRoomInfo, err)
}
+ profileConsumer(profile)
+
logger.Info("Getting stream url...")
urlInfo, err := AutoRetryWithConfig(
ctx,
diff --git a/recording/task.go b/recording/task.go
index 26f3638..43b6678 100644
--- a/recording/task.go
+++ b/recording/task.go
@@ -10,6 +10,7 @@ import (
"fmt"
"github.com/keuin/slbr/common/retry"
"github.com/keuin/slbr/logging"
+ "sync/atomic"
"time"
)
@@ -51,7 +52,16 @@ type RunningTask struct {
// hookStopped: called asynchronously when the task is stopped. This won't be called when restarting.
hookStopped func()
// logger: where to print logs
- logger logging.Logger
+ logger logging.Logger
+ roomTitle atomic.Pointer[string]
+}
+
+func (t *RunningTask) GetStatus() TaskStatus {
+ return t.status
+}
+
+func (t *RunningTask) GetRoomTitle() *string {
+ return t.roomTitle.Load()
}
func NewRunningTask(
@@ -60,8 +70,8 @@ func NewRunningTask(
hookStarted func(),
hookStopped func(),
logger logging.Logger,
-) RunningTask {
- return RunningTask{
+) *RunningTask {
+ return &RunningTask{
TaskConfig: config,
ctx: ctx,
status: StNotStarted,