customAuthParam
*/
const (
- Uid = 0
Protover = 2
Platform = "web"
Type = 2
var (
+ Uid = 0//client uid
+
Live []string//直播链接
Live_qn string
Roomid int
Url:"https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=" + Roomid,
Header:map[string]string{
`Referer`:"https://live.bilibili.com/" + Roomid,
+ `Cookie`:c.Cookie,
},
Timeout:10,
Retry:2,
Url:"https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo?type=0&id=" + Roomid,
Header:map[string]string{
`Referer`:"https://live.bilibili.com/" + Roomid,
+ `Cookie`:c.Cookie,
},
Timeout:10,
Retry:2,
Url:"https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuMedalAnchorInfo?ruid=" + uid,
Header:map[string]string{
`Referer`:"https://live.bilibili.com/" + strconv.Itoa(c.Roomid),
+ `Cookie`:c.Cookie,
},
Timeout:10,
Retry:2,
`Pragma`: `no-cache`,
`Cache-Control`: `no-cache`,
`Referer`:"https://live.bilibili.com/" + strconv.Itoa(c.Roomid),
+ `Cookie`:c.Cookie,
},
Timeout:3,
Retry:2,
`Pragma`: `no-cache`,
`Cache-Control`: `no-cache`,
`Referer`:"https://live.bilibili.com/" + strconv.Itoa(c.Roomid),
+ `Cookie`:c.Cookie,
},
Timeout:3,
Retry:2,
}
var server *http.Server
{//生成二维码
+ if p.Checkfile().IsExist(`qr.png`) {
+ apilog.Base(1,`Get_cookie`).E(`qr.png已存在`)
+ return
+ }
qr.WriteFile(img_url,qr.Medium,256,`qr.png`)
if !p.Checkfile().IsExist(`qr.png`) {
apilog.Base(1,`Get_cookie`).E(`qr error`)
Header:map[string]string{
`Content-Type`:`application/x-www-form-urlencoded; charset=UTF-8`,
`Referer`: `https://passport.bilibili.com/login`,
+ `Cookie`:c.Cookie,
},
Timeout:10,
Retry:2,
"fmt"
"flag"
"time"
+ "net/url"
"strconv"
"os"
"os/signal"
p "github.com/qydysky/part"
ws "github.com/qydysky/part/websocket"
+ g "github.com/qydysky/part/get"
reply "github.com/qydysky/bili_danmu/Reply"
c "github.com/qydysky/bili_danmu/CV"
F "github.com/qydysky/bili_danmu/F"
<-change_room_chan
for !exit_sign {
- //获取房间相关信息
- api := F.New_api(c.Roomid).Get_host_Token().Get_live()
- c.Roomid = api.Roomid
-
//获取cookies
{
var q = p.Filel{
q.File = "cookie.txt"
f := p.File().FileWR(q)
c.Cookie = f
+ if tmp_uid,e := g.SS(f,`DedeUserID=`,`;`,0,0);e == nil {
+ if v,e := strconv.Atoi(tmp_uid);e == nil {
+ c.Uid = v
+ } else {danmulog.E(e)}
+ } else {danmulog.E(e)}
} else {
danmulog.I("未检测到cookie.txt,如果需要登录请在本机打开以下网址扫码登录,不需要请忽略")
go func(){//获取cookie
- api.Get_cookie()
+ F.New_api(c.Roomid).Get_cookie()
if c.Cookie != `` {
danmulog.I("你已登录,刷新房间!")
c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{//刷新
p.Sys().Timeoutf(3)
}
}
+
+ //获取房间相关信息
+ api := F.New_api(c.Roomid).Get_host_Token().Get_live()
+ c.Roomid = api.Roomid
+
//获取用户版本
api.Get_Version()
//切换粉丝牌,只在cookie存在时启用
//对每个弹幕服务器尝试
for _, v := range api.Url {
//ws启动
+ u, _ := url.Parse(v)
ws_c := ws.New_client(ws.Client{
Url:v,
TO:35 * 1000,
Func_abort_close:func(){danmulog.I(`服务器连接中断`)},
Func_normal_close:func(){danmulog.I(`服务器连接关闭`)},
- Header:map[string][]string{
- "Cookie":[]string{c.Cookie},
+ Header: map[string]string{
+ `Cookie`:c.Cookie,
+ `Host`: u.Hostname(),
+ `User-Agent`: `Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0`,
+ `Accept`: `*/*`,
+ `Accept-Language`: `zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2`,
+ `Origin`: `https://live.bilibili.com`,
+ `Pragma`: `no-cache`,
+ `Cache-Control`: `no-cache`,
},
}).Handle()
if ws_c.Isclose() {
github.com/miekg/dns v1.1.35 // indirect
github.com/mitchellh/mapstructure v1.4.0 // indirect
github.com/qydysky/bili_danmu v0.5.4
- github.com/qydysky/part v0.3.5-0.20201222061900-d0c0ca9fc246 // indirect
+ github.com/qydysky/part v0.3.5-0.20201222075205-70243aca6682 // indirect
github.com/shirou/gopsutil v3.20.11+incompatible // indirect
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
golang.org/x/crypto v0.0.0-20201217014255-9d1352758620 // indirect
github.com/qydysky/part v0.3.4/go.mod h1:93s9ohLtzULet5ZPEUUWrT9BELC30oDZgRpgGSiDye4=
github.com/qydysky/part v0.3.5-0.20201222061900-d0c0ca9fc246 h1:MDhL/WQ4fGNjLWncGThw5JpI6AbxCvpiVIASOFIM464=
github.com/qydysky/part v0.3.5-0.20201222061900-d0c0ca9fc246/go.mod h1:SxxNav0Z7DbsDLoG5uxo0wW5EKU/JBu2CAkZzZeLnX0=
+github.com/qydysky/part v0.3.5-0.20201222075205-70243aca6682 h1:k7YM2PUXxW96cIAludM1zJ4c9Ru6/W5jxJ67HrUht3w=
+github.com/qydysky/part v0.3.5-0.20201222075205-70243aca6682/go.mod h1:SxxNav0Z7DbsDLoG5uxo0wW5EKU/JBu2CAkZzZeLnX0=
github.com/qydysky/part/msgq v0.0.0-20201213031129-ca3253dc72ad h1:Jtzf509lQrkUMGTV0Sc6IDCAiR1VrBcHrIban7hpye4=
github.com/qydysky/part/msgq v0.0.0-20201213031129-ca3253dc72ad/go.mod h1:w32TkJNVtTJd4LOS09cq+4uYG6itcN2vsqw+slp44Rg=
github.com/qydysky/part/msgq v0.0.0-20201213120821-f36e49c32bba h1:1ew9dRpc0Rux0WkWeT/4AE15ynYWmL2D7onJEJIFOB8=