From ae247555988cbaade8cafe8f0cde53158f2e325b Mon Sep 17 00:00:00 2001 From: qydysky Date: Mon, 13 May 2024 19:18:19 +0000 Subject: [PATCH] Fix Html Fail --- F/api.go | 128 +++++++++++++++++++++++++++++++++--------- F/biliApiInterface.go | 63 +++++++++++++++++++++ go.mod | 2 +- go.sum | 4 +- 4 files changed, 169 insertions(+), 28 deletions(-) diff --git a/F/api.go b/F/api.go index 596e1fe..09bb291 100644 --- a/F/api.go +++ b/F/api.go @@ -2,7 +2,6 @@ package F import ( "crypto/md5" - "encoding/json" "errors" "fmt" "net/http" @@ -24,7 +23,6 @@ import ( cmp "github.com/qydysky/part/component2" file "github.com/qydysky/part/file" funcCtrl "github.com/qydysky/part/funcCtrl" - g "github.com/qydysky/part/get" pio "github.com/qydysky/part/io" limit "github.com/qydysky/part/limit" reqf "github.com/qydysky/part/reqf" @@ -311,28 +309,13 @@ func (t *GetFunc) Html() (missKey []string) { return } - Roomid := strconv.Itoa(t.Roomid) - //html { - r := g.Get(reqf.Rval{ - Url: "https://live.bilibili.com/" + Roomid, - Proxy: t.Proxy, - }) - if tmp := r.S(``, 0, 0); tmp.Err != nil { - apilog.L(`E: `, `不存在`) + if err, j := biliApi.LiveHtml(t.Roomid); err != nil { + apilog.L(`E: `, err) + return } else { - s := tmp.RS[0] - - var j J.NEPTUNE_IS_MY_WAIFU - if e := json.Unmarshal([]byte(s), &j); e != nil { - apilog.L(`E: `, e) - return - } else if j.RoomInitRes.Code != 0 { - apilog.L(`E: `, j.RoomInitRes.Message) - return - } //Roominitres { //主播uid @@ -391,7 +374,26 @@ func (t *GetFunc) Html() (missKey []string) { } // 配置直播流 -func (t *GetFunc) configStreamType(sts []J.StreamType) { +func (t *GetFunc) configStreamType(sts []struct { + ProtocolName string + Format []struct { + FormatName string + Codec []struct { + CodecName string + CurrentQn int + AcceptQn []int + BaseURL string + URLInfo []struct { + Host string + Extra string + StreamTTL int + } + HdrQn any + DolbyType int + AttrName string + } + } +}) { var ( wantTypes []c.StreamType chosen int = -1 @@ -588,9 +590,47 @@ func (t *GetFunc) getRoomPlayInfo() (missKey []string) { } //当前直播流 - var s = make([]J.StreamType, len(res.Streams)) + var s = make([]struct { + ProtocolName string + Format []struct { + FormatName string + Codec []struct { + CodecName string + CurrentQn int + AcceptQn []int + BaseURL string + URLInfo []struct { + Host string + Extra string + StreamTTL int + } + HdrQn any + DolbyType int + AttrName string + } + } + }, len(res.Streams)) for i := 0; i < len(res.Streams); i++ { - s[i] = J.StreamType(res.Streams[i]) + s[i] = struct { + ProtocolName string + Format []struct { + FormatName string + Codec []struct { + CodecName string + CurrentQn int + AcceptQn []int + BaseURL string + URLInfo []struct { + Host string + Extra string + StreamTTL int + } + HdrQn any + DolbyType int + AttrName string + } + } + }(res.Streams[i]) } t.configStreamType(s) } @@ -652,9 +692,47 @@ func (t *GetFunc) getRoomPlayInfoByQn() (missKey []string) { } //当前直播流 - var s = make([]J.StreamType, len(res.Streams)) + var s = make([]struct { + ProtocolName string + Format []struct { + FormatName string + Codec []struct { + CodecName string + CurrentQn int + AcceptQn []int + BaseURL string + URLInfo []struct { + Host string + Extra string + StreamTTL int + } + HdrQn any + DolbyType int + AttrName string + } + } + }, len(res.Streams)) for i := 0; i < len(res.Streams); i++ { - s[i] = J.StreamType(res.Streams[i]) + s[i] = struct { + ProtocolName string + Format []struct { + FormatName string + Codec []struct { + CodecName string + CurrentQn int + AcceptQn []int + BaseURL string + URLInfo []struct { + Host string + Extra string + StreamTTL int + } + HdrQn any + DolbyType int + AttrName string + } + } + }(res.Streams[i]) } t.configStreamType(s) } diff --git a/F/biliApiInterface.go b/F/biliApiInterface.go index 1ca0534..0d953ee 100644 --- a/F/biliApiInterface.go +++ b/F/biliApiInterface.go @@ -134,4 +134,67 @@ type biliApiInter interface { Uname string Is_live bool }) + LiveHtml(Roomid int) (err error, res struct { + RoomInitRes struct { + Code int + Message string + TTL int + Data struct { + RoomID int + UID int + LiveStatus int + LiveTime int + PlayurlInfo struct { + ConfJSON string + Playurl struct { + Stream []struct { + ProtocolName string + Format []struct { + FormatName string + Codec []struct { + CodecName string + CurrentQn int + AcceptQn []int + BaseURL string + URLInfo []struct { + Host string + Extra string + StreamTTL int + } + HdrQn any + DolbyType int + AttrName string + } + } + } + } + } + } + } + RoomInfoRes struct { + Code int + Message string + TTL int + Data struct { + RoomInfo struct { + Title string + LockStatus int + AreaID int + ParentAreaID int + } + AnchorInfo struct { + BaseInfo struct { + Uname string + } + } + PopularRankInfo struct { + Rank int + RankName string + } + GuardInfo struct { + Count int + } + } + } + }) } diff --git a/go.mod b/go.mod index c56e79e..61449e6 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( require ( github.com/google/uuid v1.6.0 - github.com/qydysky/biliApi v0.0.0-20240512142342-157ceab517d0 + github.com/qydysky/biliApi v0.0.0-20240513191013-9035390b13c0 golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f ) diff --git a/go.sum b/go.sum index 852bd0a..c9fb64a 100644 --- a/go.sum +++ b/go.sum @@ -46,8 +46,8 @@ github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdh github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/qydysky/biliApi v0.0.0-20240512142342-157ceab517d0 h1:t4plypquYcyTTuyq6BGglvh05S7RrHFgD80zq9ILHgQ= -github.com/qydysky/biliApi v0.0.0-20240512142342-157ceab517d0/go.mod h1:om024vfxALQ5vxsbaGoMm8IS0esLYBnEOpJI8FsGoDg= +github.com/qydysky/biliApi v0.0.0-20240513191013-9035390b13c0 h1:mPP9ElJlVbXG7st/11LrIRw8zF8lEzagalzO4Nz9EHM= +github.com/qydysky/biliApi v0.0.0-20240513191013-9035390b13c0/go.mod h1:om024vfxALQ5vxsbaGoMm8IS0esLYBnEOpJI8FsGoDg= github.com/qydysky/part v0.28.20240501130702 h1:0riRs+hY628Hd3ohvxAgDN9GL0GpqgPe/G/YIPn8JiQ= github.com/qydysky/part v0.28.20240501130702/go.mod h1:VMq3GnrK1/7zUufW3foG5oLAk9dw567JmuMyKPTGswc= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= -- 2.39.2