@@ -538,46 +538,107 @@ func (t *biliApi) GetOnlineGoldRank(upUid int, roomid int) (err error, OnlineNum
538538 req := t .pool .Get ()
539539 defer t .pool .Put (req )
540540
541- err = req .Reqf (reqf.Rval {
542- Url : fmt .Sprintf ("https://api.live.bilibili.com/xlive/general-interface/v1/rank/getOnlineGoldRank?ruid=%d&roomId=%d&page=1&pageSize=10" , upUid , roomid ),
543- Header : map [string ]string {
544- `Host` : `api.live.bilibili.com` ,
545- `User-Agent` : UA ,
546- `Accept` : `application/json, text/plain, */*` ,
547- `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` ,
548- `Accept-Encoding` : `gzip, deflate, br` ,
549- `Origin` : `https://live.bilibili.com` ,
550- `Connection` : `keep-alive` ,
551- `Pragma` : `no-cache` ,
552- `Cache-Control` : `no-cache` ,
553- `Cookie` : t .GetCookiesS (),
554- },
555- Proxy : t .proxy ,
556- Timeout : 3 * 1000 ,
557- })
558- if err != nil {
559- return
560- }
561- var j struct {
562- Code int `json:"code"`
563- Message string `json:"message"`
564- TTL int `json:"ttl"`
565- Data struct {
566- OnlineNum int `json:"onlineNum"`
567- } `json:"data"`
568- }
541+ // api queryContributionRank
542+ {
543+ query := fmt .Sprintf ("ruid=%d&room_id=%d&page=1&page_size=100&type=online_rank&switch=contribution_rank&platform=web&web_location=444.8" , upUid , roomid )
569544
570- err = json .Unmarshal (req .Respon , & j )
571- if err != nil {
572- return
573- } else if j .Code != 0 {
574- err = errors .New (j .Message )
575- return
545+ if e , v := t .GetNav (); e != nil {
546+ err = e
547+ return
548+ } else if e , queryE := t .Wbi (query , v .WbiImg ); e != nil {
549+ err = e
550+ return
551+ } else {
552+ query = queryE
553+ }
554+
555+ err = req .Reqf (reqf.Rval {
556+ Url : "https://api.live.bilibili.com/xlive/general-interface/v1/rank/queryContributionRank?" + query ,
557+ Header : map [string ]string {
558+ `Host` : `api.live.bilibili.com` ,
559+ `User-Agent` : UA ,
560+ `Accept` : `application/json, text/plain, */*` ,
561+ `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` ,
562+ `Accept-Encoding` : `gzip, deflate, br` ,
563+ `Origin` : `https://live.bilibili.com` ,
564+ `Connection` : `keep-alive` ,
565+ `Pragma` : `no-cache` ,
566+ `Cache-Control` : `no-cache` ,
567+ `Cookie` : t .GetCookiesS (),
568+ },
569+ Proxy : t .proxy ,
570+ Timeout : 3 * 1000 ,
571+ })
572+ if err == nil {
573+ var j struct {
574+ Code int `json:"code"`
575+ Message string `json:"message"`
576+ TTL int `json:"ttl"`
577+ Data struct {
578+ Count int `json:"count"`
579+ } `json:"data"`
580+ }
581+
582+ err = json .Unmarshal (req .Respon , & j )
583+ if err != nil {
584+ return
585+ } else if j .Code != 0 {
586+ err = errors .New (j .Message )
587+ return
588+ }
589+
590+ OnlineNum = j .Data .Count
591+
592+ t .SetCookies (req .Response .Cookies ())
593+ return
594+ }
576595 }
577596
578- OnlineNum = j .Data .OnlineNum
597+ // api getOnlineGoldRank
598+ {
599+
600+ err = req .Reqf (reqf.Rval {
601+ Url : fmt .Sprintf ("https://api.live.bilibili.com/xlive/general-interface/v1/rank/getOnlineGoldRank?ruid=%d&roomId=%d&page=1&pageSize=10" , upUid , roomid ),
602+ Header : map [string ]string {
603+ `Host` : `api.live.bilibili.com` ,
604+ `User-Agent` : UA ,
605+ `Accept` : `application/json, text/plain, */*` ,
606+ `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` ,
607+ `Accept-Encoding` : `gzip, deflate, br` ,
608+ `Origin` : `https://live.bilibili.com` ,
609+ `Connection` : `keep-alive` ,
610+ `Pragma` : `no-cache` ,
611+ `Cache-Control` : `no-cache` ,
612+ `Cookie` : t .GetCookiesS (),
613+ },
614+ Proxy : t .proxy ,
615+ Timeout : 3 * 1000 ,
616+ })
617+ if err == nil {
618+ var j struct {
619+ Code int `json:"code"`
620+ Message string `json:"message"`
621+ TTL int `json:"ttl"`
622+ Data struct {
623+ OnlineNum int `json:"onlineNum"`
624+ } `json:"data"`
625+ }
626+
627+ err = json .Unmarshal (req .Respon , & j )
628+ if err != nil {
629+ return
630+ } else if j .Code != 0 {
631+ err = errors .New (j .Message )
632+ return
633+ }
634+
635+ OnlineNum = j .Data .OnlineNum
636+
637+ t .SetCookies (req .Response .Cookies ())
638+ return
639+ }
640+ }
579641
580- t .SetCookies (req .Response .Cookies ())
581642 return
582643}
583644
0 commit comments