diff options
Diffstat (limited to 'recording/watcher.go')
-rw-r--r-- | recording/watcher.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/recording/watcher.go b/recording/watcher.go index 13610a4..dd3bfa8 100644 --- a/recording/watcher.go +++ b/recording/watcher.go @@ -3,7 +3,7 @@ package recording import ( "context" "encoding/json" - "github.com/keuin/slbr/common" + "github.com/keuin/slbr/bilibili/errors" "github.com/keuin/slbr/danmaku" "github.com/keuin/slbr/danmaku/dmmsg" "github.com/keuin/slbr/danmaku/dmpkg" @@ -51,7 +51,7 @@ func watch( // connect to danmaku server for live online/offline notifications err = dm.Connect(ctx, url) if err != nil { - return common.NewRecoverableTaskError("failed to connect to danmaku server", err) + return errors.NewRecoverableTaskError("failed to connect to danmaku server", err) } defer func() { // this operation may be time-consuming, so run in another goroutine @@ -64,7 +64,7 @@ func watch( logger.Info("ws connected. Authenticating...") err = dm.Authenticate(t.RoomId, authKey) if err != nil { - return common.NewUnrecoverableTaskError("authentication failed, invalid protocol", err) + return errors.NewUnrecoverableTaskError("authentication failed, invalid protocol", err) } // the danmaku server requires heartbeat messages every 30 seconds @@ -76,7 +76,7 @@ func watch( // send initial heartbeat immediately err = heartbeat() if err != nil { - return common.NewRecoverableTaskError("heartbeat failed", err) + return errors.NewRecoverableTaskError("heartbeat failed", err) } // create heartbeat timer @@ -86,7 +86,7 @@ func watch( logger.Info("Checking initial live status...") isLiving, err := AutoRetryWithConfig[bool](ctx, logger, &t, liveStatusChecker) if err != nil { - return common.NewRecoverableTaskError("check initial live status failed", err) + return errors.NewRecoverableTaskError("check initial live status failed", err) } if isLiving { logger.Info("The live is already started. Start recording immediately.") @@ -102,18 +102,18 @@ func watch( case <-heartBeatTimer.C: err = heartbeat() if err != nil { - return common.NewRecoverableTaskError("heartbeat failed", err) + return errors.NewRecoverableTaskError("heartbeat failed", err) } default: var msg dmpkg.DanmakuExchange msg, err = dm.ReadExchange() if err != nil { - return common.NewRecoverableTaskError("failed to read exchange from server", err) + return errors.NewRecoverableTaskError("failed to read exchange from server", err) } // the exchange may be compressed msg, err = msg.Inflate() if err != nil { - return common.NewUnrecoverableTaskError("failed to decompress server message", err) + return errors.NewUnrecoverableTaskError("failed to decompress server message", err) } switch msg.Operation { @@ -123,7 +123,7 @@ func watch( err := json.Unmarshal(msg.Body, &info) if err != nil { logger.Error("Invalid JSON: \"%v\", exchange: %v", string(msg.Body), msg) - return common.NewUnrecoverableTaskError("invalid JSON response from server", err) + return errors.NewUnrecoverableTaskError("invalid JSON response from server", err) } switch info.Command { case CommandLiveStart: |