support short roomid (less than 1000)

This commit is contained in:
Akiba
2022-03-24 18:57:39 +08:00
parent 68cca0e21d
commit e26f3c1080

View File

@@ -3,6 +3,7 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Akegarasu/blivedm-go/api"
"github.com/Akegarasu/blivedm-go/packet"
"github.com/gorilla/websocket"
log "github.com/sirupsen/logrus"
@@ -29,6 +30,14 @@ func NewClient(roomID string) *Client {
}
func (c *Client) Connect() error {
rid, _ := strconv.Atoi(c.roomID)
if rid <= 1000 {
realID, err := api.GetRoomRealID(c.roomID)
if err != nil {
return err
}
c.roomID = realID
}
if c.host == "" {
info, err := getDanmuInfo(c.roomID)
if err != nil {