From: qydysky Date: Sun, 20 Dec 2020 13:57:30 +0000 (+0800) Subject: 没牌就不戴 X-Git-Tag: v0.5.5~1^2~5 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=77e46f687f1000af462a3e95075229634982ffdf;p=bili_danmu%2F.git 没牌就不戴 --- 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弹幕窗