]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Fix Html Fail
authorqydysky <qydysky@foxmail.com>
Mon, 13 May 2024 19:18:19 +0000 (19:18 +0000)
committerqydysky <qydysky@foxmail.com>
Mon, 13 May 2024 19:18:19 +0000 (19:18 +0000)
F/api.go
F/biliApiInterface.go
go.mod
go.sum

index 596e1fe24a5feef343dcecb8241d8a52c367ad73..09bb291d84e58e22f67bfa0eeeb88cc53002776f 100644 (file)
--- 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(`<script>window.__NEPTUNE_IS_MY_WAIFU__=`, `</script>`, 0, 0); tmp.Err != nil {
-                       apilog.L(`E: `, `不存在<script>window.__NEPTUNE_IS_MY_WAIFU__= </script>`)
+               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)
                }
index 1ca053434c76cbdf0212b3c837ab4040da8e102e..0d953eedf7afb1152866d0fb8b7cadaabcf10ec1 100644 (file)
@@ -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 c56e79e07bf236f5d2a8e8731b37f92d197f204f..61449e6a3b054ea7c240532b7db068a9ef420547 100644 (file)
--- 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 852bd0ac54f8487be2d6f6641a70e5b32ade8cba..c9fb64a22d3e23aa41f03ef94fdab99da1e769e3 100644 (file)
--- 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=