From 77e46f687f1000af462a3e95075229634982ffdf Mon Sep 17 00:00:00 2001 From: qydysky Date: Sun, 20 Dec 2020 21:57:30 +0800 Subject: [PATCH] =?utf8?q?=E6=B2=A1=E7=89=8C=E5=B0=B1=E4=B8=8D=E6=88=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- F/api.go | 20 ++++++++++++++++---- README.md | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/F/api.go b/F/api.go index ee61ec6..8d54e06 100644 --- a/F/api.go +++ b/F/api.go @@ -774,9 +774,12 @@ func (i *api) Switch_FansMedal() { return } } - if medal_id == 0 {return} } - {//切换牌子 + var ( + post_url string + post_str string + ) + {//生成佩戴信息 var csrf string if i := strings.Index(c.Cookie, "bili_jct="); i == -1 { apilog.Base(1,`Switch_FansMedal`).E("Cookie错误,无bili_jct=") @@ -788,10 +791,19 @@ func (i *api) Switch_FansMedal() { csrf = c.Cookie[i + 9:][:d] } } + post_str = `csrf_token=`+csrf+`&csrf=`+csrf + if medal_id == 0 {//无牌,不佩戴牌子 + post_url = `https://api.live.bilibili.com/xlive/web-room/v1/fansMedal/take_off` + } else { + post_url = `https://api.live.bilibili.com/xlive/web-room/v1/fansMedal/wear` + post_str = `medal_id=`+strconv.Itoa(medal_id)+`&`+post_str + } + } + {//切换牌子 r := p.Req() if e := r.Reqf(p.Rval{ - Url:`https://api.live.bilibili.com/xlive/web-room/v1/fansMedal/wear`, - PostStr:`medal_id=`+strconv.Itoa(medal_id)+`&csrf_token=`+csrf+`&csrf=`+csrf, + Url:post_url, + PostStr:post_str, Header:map[string]string{ `Cookie`:c.Cookie, `Content-Type`:`application/x-www-form-urlencoded; charset=UTF-8`, diff --git a/README.md b/README.md index c1558a0..930b0ae 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ golang go version go1.15.5 linux/amd64 #### 当前支持功能 以下内容可能过时,点击查看[当前支持功能](https://github.com/qydysky/bili_danmu/blob/master/Reply/F.go#L16) +- [x] 自动切换粉丝牌 - [x] 扫码登录 - [x] 自定义语音提醒 - [x] GTK弹幕窗 -- 2.39.2