]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Fix 保持粉丝牌点亮
authorqydysky <qydysky@foxmail.com>
Mon, 3 Jul 2023 06:57:27 +0000 (14:57 +0800)
committerqydysky <qydysky@foxmail.com>
Mon, 3 Jul 2023 06:57:27 +0000 (14:57 +0800)
F/api.go
Json/fansMedal.go
Reply/F.go

index f29e795f918bfc65c447e352fb3ac1c206693415..a971ceb78afc4ace92f3e832e5996aa172426eed 100644 (file)
--- a/F/api.go
+++ b/F/api.go
@@ -1475,8 +1475,16 @@ func Get_cookie_by_msg() {
        /*https://passport.bilibili.com/x/passport-login/web/sms/send*/
 }
 
+// 牌子字段
+type FansMedalI struct {
+       TargetID  int
+       IsLighted int
+       MedalID   int
+       RoomID    int
+}
+
 // 获取牌子信息
-func Get_list_in_room() (array []J.GetMyMedals_Items) {
+func Get_list_in_room() (array []FansMedalI) {
 
        apilog := apilog.Base_add(`获取牌子`)
        //验证cookie
@@ -1495,12 +1503,12 @@ func Get_list_in_room() (array []J.GetMyMedals_Items) {
        })
 
        { //获取牌子列表
-               var medalList []J.GetMyMedals_Items
+               var medalList []FansMedalI
                for pageNum := 1; true; pageNum += 1 {
                        r := c.C.ReqPool.Get()
                        defer c.C.ReqPool.Put(r)
                        if e := r.Reqf(reqf.Rval{
-                               Url: `https://api.live.bilibili.com/xlive/app-ucenter/v1/user/GetMyMedals?page=` + strconv.Itoa(pageNum) + `&page_size=10`,
+                               Url: `https://api.live.bilibili.com/xlive/app-ucenter/v1/fansMedal/panel?page=` + strconv.Itoa(pageNum) + `&page_size=10`,
                                Header: map[string]string{
                                        `Cookie`: reqf.Map_2_Cookies_String(Cookie),
                                },
@@ -1512,7 +1520,7 @@ func Get_list_in_room() (array []J.GetMyMedals_Items) {
                                return
                        }
 
-                       var res J.GetMyMedals
+                       var res J.FansMedal
 
                        if e := json.Unmarshal(r.Respon, &res); e != nil {
                                apilog.L(`E: `, e)
@@ -1523,9 +1531,17 @@ func Get_list_in_room() (array []J.GetMyMedals_Items) {
                                return
                        }
 
-                       medalList = append(medalList, res.Data.Items...)
+                       for i := 0; i < len(res.Data.List); i++ {
+                               li := res.Data.List[i]
+                               medalList = append(medalList, FansMedalI{
+                                       TargetID:  li.Medal.TargetID,
+                                       IsLighted: li.Medal.IsLighted,
+                                       MedalID:   li.Medal.MedalID,
+                                       RoomID:    li.RoomInfo.RoomID,
+                               })
+                       }
 
-                       if res.Data.PageInfo.CurPage == res.Data.PageInfo.TotalPage {
+                       if res.Data.PageInfo.CurrentPage == res.Data.PageInfo.TotalPage {
                                break
                        }
 
index b6af0949b784f78a87ef7be5f8fbf426c986d546..568db5caeb19f339d573276f7e24b21bb719cce1 100644 (file)
@@ -5,5 +5,93 @@ type FansMedal struct {
        Message string `json:"message"`
        TTL     int    `json:"ttl"`
        Data    struct {
+               List []struct {
+                       Medal      FansMedalItem `json:"medal"`
+                       AnchorInfo struct {
+                               NickName string `json:"nick_name"`
+                               Avatar   string `json:"avatar"`
+                               Verify   int    `json:"verify"`
+                       } `json:"anchor_info"`
+                       Superscript interface{} `json:"superscript"`
+                       RoomInfo    struct {
+                               RoomID       int    `json:"room_id"`
+                               LivingStatus int    `json:"living_status"`
+                               URL          string `json:"url"`
+                       } `json:"room_info"`
+               } `json:"list"`
+               SpecialList []struct {
+                       Medal struct {
+                               UID              int    `json:"uid"`
+                               TargetID         int    `json:"target_id"`
+                               TargetName       string `json:"target_name"`
+                               MedalID          int    `json:"medal_id"`
+                               Level            int    `json:"level"`
+                               MedalName        string `json:"medal_name"`
+                               MedalColor       int    `json:"medal_color"`
+                               Intimacy         int    `json:"intimacy"`
+                               NextIntimacy     int    `json:"next_intimacy"`
+                               DayLimit         int    `json:"day_limit"`
+                               TodayFeed        int    `json:"today_feed"`
+                               MedalColorStart  int    `json:"medal_color_start"`
+                               MedalColorEnd    int    `json:"medal_color_end"`
+                               MedalColorBorder int    `json:"medal_color_border"`
+                               IsLighted        int    `json:"is_lighted"`
+                               GuardLevel       int    `json:"guard_level"`
+                               WearingStatus    int    `json:"wearing_status"`
+                               MedalIconID      int    `json:"medal_icon_id"`
+                               MedalIconURL     string `json:"medal_icon_url"`
+                               GuardIcon        string `json:"guard_icon"`
+                               HonorIcon        string `json:"honor_icon"`
+                               CanDelete        bool   `json:"can_delete"`
+                       } `json:"medal"`
+                       AnchorInfo struct {
+                               NickName string `json:"nick_name"`
+                               Avatar   string `json:"avatar"`
+                               Verify   int    `json:"verify"`
+                       } `json:"anchor_info"`
+                       Superscript interface{} `json:"superscript"`
+                       RoomInfo    struct {
+                               RoomID       int    `json:"room_id"`
+                               LivingStatus int    `json:"living_status"`
+                               URL          string `json:"url"`
+                       } `json:"room_info"`
+               } `json:"special_list"`
+               BottomBar interface{} `json:"bottom_bar"`
+               PageInfo  struct {
+                       Number          int  `json:"number"`
+                       CurrentPage     int  `json:"current_page"`
+                       HasMore         bool `json:"has_more"`
+                       NextPage        int  `json:"next_page"`
+                       NextLightStatus int  `json:"next_light_status"`
+                       TotalPage       int  `json:"total_page"`
+               } `json:"page_info"`
+               TotalNumber int `json:"total_number"`
+               HasMedal    int `json:"has_medal"`
        } `json:"data"`
 }
+
+type FansMedalItem struct {
+       UID              int    `json:"uid"`
+       TargetID         int    `json:"target_id"`
+       TargetName       string `json:"target_name"`
+       MedalID          int    `json:"medal_id"`
+       Level            int    `json:"level"`
+       MedalName        string `json:"medal_name"`
+       MedalColor       int    `json:"medal_color"`
+       Intimacy         int    `json:"intimacy"`
+       NextIntimacy     int    `json:"next_intimacy"`
+       DayLimit         int    `json:"day_limit"`
+       TodayFeed        int    `json:"today_feed"`
+       MedalColorStart  int    `json:"medal_color_start"`
+       MedalColorEnd    int    `json:"medal_color_end"`
+       MedalColorBorder int    `json:"medal_color_border"`
+       IsLighted        int    `json:"is_lighted"`
+       GuardLevel       int    `json:"guard_level"`
+       WearingStatus    int    `json:"wearing_status"`
+       MedalIconID      int    `json:"medal_icon_id"`
+       MedalIconURL     string `json:"medal_icon_url"`
+       GuardIcon        string `json:"guard_icon"`
+       HonorIcon        string `json:"honor_icon"`
+       CanDelete        bool   `json:"can_delete"`
+}
+
index 54caee4ff2efe8c47b2a1bf28c5233f730ead8b6..094b0be6ba08d12d0b519aa5776dbcd90c67d9c4 100644 (file)
@@ -31,7 +31,6 @@ import (
        "github.com/dustin/go-humanize"
        c "github.com/qydysky/bili_danmu/CV"
        F "github.com/qydysky/bili_danmu/F"
-       J "github.com/qydysky/bili_danmu/Json"
        send "github.com/qydysky/bili_danmu/Send"
 
        p "github.com/qydysky/part"
@@ -998,27 +997,19 @@ func Keep_medal_light() {
        flog.L(`T: `, `开始`)
        defer flog.L(`I: `, `完成`)
 
-       cacheInfo := make(map[int]J.Info)
        medals := F.Get_list_in_room()
        if len(medals) == 0 {
                return
        }
        for _, v := range medals {
-               if v.IsLighted == 1 {
+               if v.IsLighted == 1 || v.RoomID == 0 {
                        continue
                } //点亮状态
 
-               if info, e := F.Get(c.C).Info(v.TargetID); e != nil {
-                       flog.L(`E: `, e)
-                       return
-               } else {
-                       cacheInfo[v.TargetID] = info
-               }
-
                //两天内到期,发弹幕续期
                rand := p.Rand().MixRandom(0, int64(len(array)-1))
-               send.Danmu_s(array[rand].(string), cacheInfo[v.TargetID].Data.LiveRoom.Roomid)
-               time.Sleep(time.Second)
+               send.Danmu_s(array[rand].(string), v.RoomID)
+               time.Sleep(time.Second * 5)
        }
 
        //重试,使用点赞
@@ -1027,7 +1018,7 @@ func Keep_medal_light() {
                return
        }
        for _, v := range medals {
-               if v.IsLighted == 1 || cacheInfo[v.TargetID].Data.LiveRoom.Roomid == 0 {
+               if v.IsLighted == 1 || v.RoomID == 0 {
                        continue
                }
 
@@ -1035,9 +1026,9 @@ func Keep_medal_light() {
                send.Danmu_s2(map[string]string{
                        `msg`:     `official_147`,
                        `dm_type`: `1`,
-                       `roomid`:  strconv.Itoa(cacheInfo[v.TargetID].Data.LiveRoom.Roomid),
+                       `roomid`:  strconv.Itoa(v.RoomID),
                })
-               time.Sleep(time.Second)
+               time.Sleep(time.Second * 5)
        }
 
        //重试,使用历史弹幕
@@ -1046,13 +1037,13 @@ func Keep_medal_light() {
                return
        }
        for _, v := range medals {
-               if v.IsLighted == 1 || cacheInfo[v.TargetID].Data.LiveRoom.Roomid == 0 {
+               if v.IsLighted == 1 || v.RoomID == 0 {
                        continue
                }
 
                //两天内到期,发弹幕续期
                var Str string
-               for _, v := range F.GetHistory(cacheInfo[v.TargetID].Data.LiveRoom.Roomid).Data.Room {
+               for _, v := range F.GetHistory(v.RoomID).Data.Room {
                        if v.Text != "" {
                                Str = v.Text
                                break
@@ -1062,8 +1053,8 @@ func Keep_medal_light() {
                        rand := p.Rand().MixRandom(0, int64(len(array)-1))
                        Str = array[rand].(string)
                }
-               send.Danmu_s(Str, cacheInfo[v.TargetID].Data.LiveRoom.Roomid)
-               time.Sleep(time.Second)
+               send.Danmu_s(Str, v.RoomID)
+               time.Sleep(time.Second * 5)
        }
 }