2026-04-05 10:36:22 +08:00
|
|
|
package bilibili
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
|
|
"github.com/CuteReimu/bilibili/v2"
|
|
|
|
|
"github.com/ssdomei232/goodBaby/handler/db"
|
|
|
|
|
"github.com/ssdomei232/goodBaby/model"
|
|
|
|
|
)
|
|
|
|
|
|
2026-07-26 22:19:41 +08:00
|
|
|
func newClient(rawCookies string) *bilibili.Client {
|
|
|
|
|
client := bilibili.New()
|
|
|
|
|
client.SetRawCookies(rawCookies)
|
|
|
|
|
return client
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 10:36:22 +08:00
|
|
|
// 获取 Bilibili Client
|
2026-04-06 10:10:31 +08:00
|
|
|
func getBiliClient(rule *model.Rule) (*bilibili.Client, error) {
|
2026-07-26 22:19:41 +08:00
|
|
|
var accountConfig BiliAccount
|
|
|
|
|
if err := db.LoadAccountConfig(rule.AccountID, &accountConfig); err != nil {
|
2026-04-05 10:36:22 +08:00
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-26 22:19:41 +08:00
|
|
|
return newClient(accountConfig.RawCookies), nil
|
2026-04-05 10:36:22 +08:00
|
|
|
}
|
2026-04-06 10:10:31 +08:00
|
|
|
|
|
|
|
|
// 获取 Bilibili Dynamic Config
|
|
|
|
|
func getBiliDynamicConfig(rule *model.Rule) (*BiliDynamicConfig, error) {
|
|
|
|
|
var biliDynamicConfig BiliDynamicConfig
|
2026-07-26 22:19:41 +08:00
|
|
|
if err := json.Unmarshal([]byte(rule.ConfigJson), &biliDynamicConfig); err != nil {
|
2026-04-06 10:10:31 +08:00
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &biliDynamicConfig, nil
|
|
|
|
|
}
|