]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Fix 定时更新LIVE_BUVID
authorqydysky <32743305+qydysky@users.noreply.github.com>
Mon, 20 Mar 2023 17:03:30 +0000 (01:03 +0800)
committerqydysky <32743305+qydysky@users.noreply.github.com>
Mon, 20 Mar 2023 17:03:30 +0000 (01:03 +0800)
CV/Var.go
F/api.go

index 01286a35a0fd63a9f106225401745bbec025d1a7..355c84600627d450d2a22610ad92540e58e2798a 100644 (file)
--- a/CV/Var.go
+++ b/CV/Var.go
@@ -55,7 +55,7 @@ type Common struct {
        Wearing_FansMedal int                   //当前佩戴的粉丝牌
        Token             string                //弹幕钥
        WSURL             []string              //弹幕链接
-       LIVE_BUVID        bool                  //cookies含LIVE_BUVID
+       LiveBuvidUpdated  time.Time             //LIVE_BUVID更新时间
        Stream_url        *url.URL              //直播Web服务
        Proxy             string                //全局代理
        AcceptQn          map[int]string        //允许的直播流质量
@@ -133,7 +133,7 @@ func (t *Common) Copy() *Common {
                Wearing_FansMedal: t.Wearing_FansMedal,
                Token:             t.Token,
                WSURL:             t.WSURL,
-               LIVE_BUVID:        t.LIVE_BUVID,
+               LiveBuvidUpdated:  t.LiveBuvidUpdated,
                Stream_url:        t.Stream_url,
                Proxy:             t.Proxy,
                AcceptQn:          syncmap.Copy(t.AcceptQn),
index db79ce573967f51f3d33723bc52753d97a741c2a..dc1a30c897094d265f42405b622350563774e633 100644 (file)
--- a/F/api.go
+++ b/F/api.go
@@ -198,7 +198,7 @@ func (c *GetFunc) Get(key string) {
                        //      return c.VERSION != `2.0.11`
                        // },
                        `LIVE_BUVID`: func() bool { //LIVE_BUVID
-                               return c.LIVE_BUVID
+                               return c.LiveBuvidUpdated.After(time.Now().Add(-time.Hour))
                        },
                        `Silver_2_coin`: func() bool { //银瓜子2硬币
                                return true
@@ -564,7 +564,7 @@ func (t *GetFunc) getRoomPlayInfo() (missKey []string) {
        if t.Roomid == 0 {
                missKey = append(missKey, `Roomid`)
        }
-       if !t.LIVE_BUVID {
+       if t.LiveBuvidUpdated.Before(time.Now().Add(-time.Hour)) {
                missKey = append(missKey, `LIVE_BUVID`)
        }
        if len(missKey) > 0 {
@@ -638,7 +638,7 @@ func (t *GetFunc) getRoomPlayInfoByQn() (missKey []string) {
        if t.Roomid == 0 {
                missKey = append(missKey, `Roomid`)
        }
-       if !t.LIVE_BUVID {
+       if t.LiveBuvidUpdated.Before(time.Now().Add(-time.Hour)) {
                missKey = append(missKey, `LIVE_BUVID`)
        }
        if len(missKey) > 0 {
@@ -731,7 +731,7 @@ func (c *GetFunc) getDanmuInfo() (missKey []string) {
        if c.Roomid == 0 {
                missKey = append(missKey, `Roomid`)
        }
-       if !c.LIVE_BUVID {
+       if c.LiveBuvidUpdated.Before(time.Now().Add(-time.Hour)) {
                missKey = append(missKey, `LIVE_BUVID`)
        }
        if len(missKey) > 0 {
@@ -992,7 +992,7 @@ func (c *GetFunc) Get_guardNum() (missKey []string) {
        if c.Roomid == 0 {
                missKey = append(missKey, `Roomid`)
        }
-       if !c.LIVE_BUVID {
+       if c.LiveBuvidUpdated.Before(time.Now().Add(-time.Hour)) {
                missKey = append(missKey, `LIVE_BUVID`)
        }
        if len(missKey) > 0 {
@@ -1572,7 +1572,7 @@ func Get_weared_medal() (item J.GetWearedMedal_Data) {
 
 func (c *GetFunc) CheckSwitch_FansMedal() (missKey []string) {
 
-       if !c.LIVE_BUVID {
+       if c.LiveBuvidUpdated.Before(time.Now().Add(-time.Hour)) {
                missKey = append(missKey, `LIVE_BUVID`)
        }
        if c.UpUid == 0 {
@@ -1805,11 +1805,11 @@ func Dosign() {
 func (c *GetFunc) Get_LIVE_BUVID() (missKey []string) {
        apilog := apilog.Base_add(`LIVE_BUVID`) //.L(`T: `, `获取`)
 
-       if live_buvid, ok := c.Cookie.LoadV(`LIVE_BUVID`).(string); ok && live_buvid != `` {
-               apilog.L(`T: `, `存在`)
-               c.LIVE_BUVID = true
-               return
-       }
+       // if live_buvid, ok := c.Cookie.LoadV(`LIVE_BUVID`).(string); ok && live_buvid != `` {
+       //      apilog.L(`T: `, `存在`)
+       //      c.LIVE_BUVID = true
+       //      return
+       // }
 
        //当房间处于特殊活动状态时,将会获取不到,此处使用了若干著名up主房间进行尝试
        roomIdList := []string{
@@ -1868,7 +1868,7 @@ func (c *GetFunc) Get_LIVE_BUVID() (missKey []string) {
 
        CookieSet([]byte(reqf.Map_2_Cookies_String(Cookie)))
 
-       c.LIVE_BUVID = true
+       c.LiveBuvidUpdated = time.Now()
 
        return
 }
@@ -1963,7 +1963,7 @@ func Gift_list() (list []Gift_list_type_Data_List) {
 func (c *GetFunc) Silver_2_coin() (missKey []string) {
        apilog := apilog.Base_add(`银瓜子=>硬币`)
 
-       if !c.LIVE_BUVID {
+       if c.LiveBuvidUpdated.Before(time.Now().Add(-time.Hour)) {
                missKey = append(missKey, `LIVE_BUVID`)
        }
        if len(missKey) > 0 {