|
|
@ -33,6 +33,7 @@ import (
|
|
|
|
"github.com/zencoder/go-dash/v3/mpd"
|
|
|
|
"github.com/zencoder/go-dash/v3/mpd"
|
|
|
|
"github.com/zijiren233/livelib/protocol/hls"
|
|
|
|
"github.com/zijiren233/livelib/protocol/hls"
|
|
|
|
"github.com/zijiren233/livelib/protocol/httpflv"
|
|
|
|
"github.com/zijiren233/livelib/protocol/httpflv"
|
|
|
|
|
|
|
|
"golang.org/x/exp/maps"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func GetPageAndPageSize(ctx *gin.Context) (int, int, error) {
|
|
|
|
func GetPageAndPageSize(ctx *gin.Context) (int, int, error) {
|
|
|
@ -680,11 +681,11 @@ func initBilibiliMPDCache(ctx context.Context, movie dbModel.Movie) func() (any,
|
|
|
|
cli := vendor.BilibiliClient(movie.Base.VendorInfo.Backend)
|
|
|
|
cli := vendor.BilibiliClient(movie.Base.VendorInfo.Backend)
|
|
|
|
var m, hevcM *mpd.MPD
|
|
|
|
var m, hevcM *mpd.MPD
|
|
|
|
biliInfo := movie.Base.VendorInfo.Bilibili
|
|
|
|
biliInfo := movie.Base.VendorInfo.Bilibili
|
|
|
|
if biliInfo.Bvid != "" && biliInfo.Cid != 0 {
|
|
|
|
switch {
|
|
|
|
resp, err := cli.GetDashVideoURL(ctx, &bilibili.GetDashVideoURLReq{
|
|
|
|
case biliInfo.Epid != 0:
|
|
|
|
|
|
|
|
resp, err := cli.GetDashPGCURL(ctx, &bilibili.GetDashPGCURLReq{
|
|
|
|
Cookies: utils.HttpCookieToMap(cookies),
|
|
|
|
Cookies: utils.HttpCookieToMap(cookies),
|
|
|
|
Bvid: biliInfo.Bvid,
|
|
|
|
Epid: biliInfo.Epid,
|
|
|
|
Cid: biliInfo.Cid,
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
@ -698,10 +699,11 @@ func initBilibiliMPDCache(ctx context.Context, movie dbModel.Movie) func() (any,
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if biliInfo.Epid != 0 {
|
|
|
|
case biliInfo.Bvid != "":
|
|
|
|
resp, err := cli.GetDashPGCURL(ctx, &bilibili.GetDashPGCURLReq{
|
|
|
|
resp, err := cli.GetDashVideoURL(ctx, &bilibili.GetDashVideoURLReq{
|
|
|
|
Cookies: utils.HttpCookieToMap(cookies),
|
|
|
|
Cookies: utils.HttpCookieToMap(cookies),
|
|
|
|
Epid: biliInfo.Epid,
|
|
|
|
Bvid: biliInfo.Bvid,
|
|
|
|
|
|
|
|
Cid: biliInfo.Cid,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
@ -714,8 +716,7 @@ func initBilibiliMPDCache(ctx context.Context, movie dbModel.Movie) func() (any,
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return nil, errors.New("bvid and epid are empty")
|
|
|
|
return nil, errors.New("bvid and epid are empty")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m.BaseURL = append(m.BaseURL, fmt.Sprintf("/api/movie/proxy/%s/", movie.RoomID))
|
|
|
|
m.BaseURL = append(m.BaseURL, fmt.Sprintf("/api/movie/proxy/%s/", movie.RoomID))
|
|
|
@ -773,28 +774,33 @@ func initBilibiliShareCache(ctx context.Context, movie dbModel.Movie) func() (an
|
|
|
|
cli := vendor.BilibiliClient(movie.Base.VendorInfo.Backend)
|
|
|
|
cli := vendor.BilibiliClient(movie.Base.VendorInfo.Backend)
|
|
|
|
var u string
|
|
|
|
var u string
|
|
|
|
biliInfo := movie.Base.VendorInfo.Bilibili
|
|
|
|
biliInfo := movie.Base.VendorInfo.Bilibili
|
|
|
|
if biliInfo.Bvid != "" {
|
|
|
|
switch {
|
|
|
|
resp, err := cli.GetVideoURL(ctx, &bilibili.GetVideoURLReq{
|
|
|
|
case biliInfo.Epid != 0:
|
|
|
|
|
|
|
|
resp, err := cli.GetPGCURL(ctx, &bilibili.GetPGCURLReq{
|
|
|
|
Cookies: utils.HttpCookieToMap(cookies),
|
|
|
|
Cookies: utils.HttpCookieToMap(cookies),
|
|
|
|
Bvid: biliInfo.Bvid,
|
|
|
|
Epid: biliInfo.Epid,
|
|
|
|
Cid: biliInfo.Cid,
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
u = resp.Url
|
|
|
|
u = resp.Url
|
|
|
|
} else if biliInfo.Epid != 0 {
|
|
|
|
|
|
|
|
resp, err := cli.GetPGCURL(ctx, &bilibili.GetPGCURLReq{
|
|
|
|
case biliInfo.Bvid != "":
|
|
|
|
|
|
|
|
resp, err := cli.GetVideoURL(ctx, &bilibili.GetVideoURLReq{
|
|
|
|
Cookies: utils.HttpCookieToMap(cookies),
|
|
|
|
Cookies: utils.HttpCookieToMap(cookies),
|
|
|
|
Epid: biliInfo.Epid,
|
|
|
|
Bvid: biliInfo.Bvid,
|
|
|
|
|
|
|
|
Cid: biliInfo.Cid,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
u = resp.Url
|
|
|
|
u = resp.Url
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
return nil, errors.New("bvid and epid are empty")
|
|
|
|
return nil, errors.New("bvid and epid are empty")
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return u, nil
|
|
|
|
return u, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -881,7 +887,17 @@ func proxyVendorMovie(ctx *gin.Context, movie *op.Movie) {
|
|
|
|
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewApiErrorStringResp("stream id out of range"))
|
|
|
|
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewApiErrorStringResp("stream id out of range"))
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
proxyURL(ctx, mpd.urls[streamId], movie.Movie.Base.Headers)
|
|
|
|
headers := maps.Clone(movie.Movie.Base.Headers)
|
|
|
|
|
|
|
|
if headers == nil {
|
|
|
|
|
|
|
|
headers = map[string]string{
|
|
|
|
|
|
|
|
"Referer": "https://www.bilibili.com",
|
|
|
|
|
|
|
|
"User-Agent": utils.UA,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
headers["Referer"] = "https://www.bilibili.com"
|
|
|
|
|
|
|
|
headers["User-Agent"] = utils.UA
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
proxyURL(ctx, mpd.urls[streamId], headers)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|