diff options
author | Keuin <[email protected]> | 2023-07-29 19:43:27 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2023-07-29 20:21:17 +0800 |
commit | 9b5c3913989754370bd7d03ac8cf2e32a6172afb (patch) | |
tree | 9e2caca8feb9ca5a9c14a96424d23e20db4314bc /recording/watcher.go | |
parent | a153bf02d1cf05f020d263e9670a76ae99cfeb02 (diff) |
Simulate real web app cookies & WebSocket fields
Diffstat (limited to 'recording/watcher.go')
-rw-r--r-- | recording/watcher.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/recording/watcher.go b/recording/watcher.go index 515def1..ff9bde1 100644 --- a/recording/watcher.go +++ b/recording/watcher.go @@ -4,7 +4,8 @@ import ( "context" "encoding/base64" "encoding/json" - errs "github.com/keuin/slbr/bilibili/errors" + errs "github.com/keuin/slbr/bilibili" + "github.com/keuin/slbr/bilibili/errors" "github.com/keuin/slbr/danmaku" "github.com/keuin/slbr/danmaku/dmmsg" "github.com/keuin/slbr/danmaku/dmpkg" @@ -41,19 +42,19 @@ func watch( ctx context.Context, t TaskConfig, url string, - authKey string, + authKey, buvid3 string, liveStatusChecker func() (bool, error), logger logging.Logger, + bi *bilibili.Bilibili, ) error { var err error - dm := danmaku.NewDanmakuClient() - - // connect to danmaku server for live online/offline notifications - err = dm.Connect(ctx, url) + ws, err := bi.DialWebSocket(ctx, url) if err != nil { return errs.NewError(errs.DanmakuServerConnection, err) } + + dm := danmaku.NewClient(ctx, ws) defer func() { // this operation may be time-consuming, so run in another goroutine go func() { @@ -63,7 +64,7 @@ func watch( // the danmaku server requires an auth token and room id when connected logger.Info("ws connected. Authenticating...") - err = dm.Authenticate(t.RoomId, authKey) + err = dm.Authenticate(t.RoomId, authKey, buvid3) if err != nil { return errs.NewError(errs.InvalidAuthProtocol, err) } |