mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-07-19 01:48:42 +08:00
feat(quark_uc_tv): add streaming link api (#728)
This commit is contained in:
@ -126,25 +126,13 @@ func (d *QuarkUCTV) List(ctx context.Context, dir model.Obj, args model.ListArgs
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *QuarkUCTV) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
|
func (d *QuarkUCTV) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
|
||||||
var fileLink FileLink
|
f := file.(*Files)
|
||||||
_, err := d.request(ctx, "/file", "GET", func(req *resty.Request) {
|
|
||||||
req.SetQueryParams(map[string]string{
|
if d.Addition.VideoLinkMethod == "streaming" && f.Category == 1 && f.Size > 0 {
|
||||||
"method": "download",
|
return d.getTranscodingLink(ctx, file)
|
||||||
"group_by": "source",
|
|
||||||
"fid": file.GetID(),
|
|
||||||
"resolution": "low,normal,high,super,2k,4k",
|
|
||||||
"support": "dolby_vision",
|
|
||||||
})
|
|
||||||
}, &fileLink)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.Link{
|
return d.getDownloadLink(ctx, file)
|
||||||
URL: fileLink.Data.DownloadURL,
|
|
||||||
Concurrency: 3,
|
|
||||||
PartSize: 10 * utils.MB,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *QuarkUCTV) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) (model.Obj, error) {
|
func (d *QuarkUCTV) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) (model.Obj, error) {
|
||||||
|
@ -14,6 +14,8 @@ type Addition struct {
|
|||||||
DeviceID string `json:"device_id" required:"false" default:""`
|
DeviceID string `json:"device_id" required:"false" default:""`
|
||||||
// 登陆所用的数据 无需手动填写
|
// 登陆所用的数据 无需手动填写
|
||||||
QueryToken string `json:"query_token" required:"false" default:"" help:"don't edit'"`
|
QueryToken string `json:"query_token" required:"false" default:"" help:"don't edit'"`
|
||||||
|
// 视频文件链接获取方式 download(可获取源视频) or streaming(获取转码后的视频)
|
||||||
|
VideoLinkMethod string `json:"link_method" required:"true" type:"select" options:"download,streaming" default:"download"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Conf struct {
|
type Conf struct {
|
||||||
@ -38,8 +40,8 @@ func init() {
|
|||||||
api: "https://open-api-drive.quark.cn",
|
api: "https://open-api-drive.quark.cn",
|
||||||
clientID: "d3194e61504e493eb6222857bccfed94",
|
clientID: "d3194e61504e493eb6222857bccfed94",
|
||||||
signKey: "kw2dvtd7p4t3pjl2d9ed9yc8yej8kw2d",
|
signKey: "kw2dvtd7p4t3pjl2d9ed9yc8yej8kw2d",
|
||||||
appVer: "1.5.6",
|
appVer: "1.8.2.2",
|
||||||
channel: "CP",
|
channel: "GENERAL",
|
||||||
codeApi: "http://api.extscreen.com/quarkdrive",
|
codeApi: "http://api.extscreen.com/quarkdrive",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -56,7 +58,7 @@ func init() {
|
|||||||
api: "https://open-api-drive.uc.cn",
|
api: "https://open-api-drive.uc.cn",
|
||||||
clientID: "5acf882d27b74502b7040b0c65519aa7",
|
clientID: "5acf882d27b74502b7040b0c65519aa7",
|
||||||
signKey: "l3srvtd7p42l0d0x1u8d7yc8ye9kki4d",
|
signKey: "l3srvtd7p42l0d0x1u8d7yc8ye9kki4d",
|
||||||
appVer: "1.6.5",
|
appVer: "1.7.2.2",
|
||||||
channel: "UCTVOFFICIALWEB",
|
channel: "UCTVOFFICIALWEB",
|
||||||
codeApi: "http://api.extscreen.com/ucdrive",
|
codeApi: "http://api.extscreen.com/ucdrive",
|
||||||
},
|
},
|
||||||
|
@ -92,7 +92,32 @@ type FilesData struct {
|
|||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileLink struct {
|
type StreamingFileLink struct {
|
||||||
|
CommonRsp
|
||||||
|
Data struct {
|
||||||
|
DefaultResolution string `json:"default_resolution"`
|
||||||
|
LastPlayTime int `json:"last_play_time"`
|
||||||
|
VideoInfo []struct {
|
||||||
|
Resolution string `json:"resolution"`
|
||||||
|
Accessable int `json:"accessable"`
|
||||||
|
TransStatus string `json:"trans_status"`
|
||||||
|
Duration int `json:"duration,omitempty"`
|
||||||
|
Size int64 `json:"size,omitempty"`
|
||||||
|
Format string `json:"format,omitempty"`
|
||||||
|
Width int `json:"width,omitempty"`
|
||||||
|
Height int `json:"height,omitempty"`
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
|
Bitrate float64 `json:"bitrate,omitempty"`
|
||||||
|
DolbyVision struct {
|
||||||
|
Profile int `json:"profile"`
|
||||||
|
Level int `json:"level"`
|
||||||
|
} `json:"dolby_vision,omitempty"`
|
||||||
|
} `json:"video_info"`
|
||||||
|
AudioInfo []interface{} `json:"audio_info"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DownloadFileLink struct {
|
||||||
CommonRsp
|
CommonRsp
|
||||||
Data struct {
|
Data struct {
|
||||||
Fid string `json:"fid"`
|
Fid string `json:"fid"`
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@ -210,3 +211,47 @@ func (d *QuarkUCTV) generateReqSign(method string, pathname string, key string)
|
|||||||
|
|
||||||
return timestamp, xPanTokenHex, reqIDHex
|
return timestamp, xPanTokenHex, reqIDHex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *QuarkUCTV) getTranscodingLink(ctx context.Context, file model.Obj) (*model.Link, error) {
|
||||||
|
var fileLink StreamingFileLink
|
||||||
|
_, err := d.request(ctx, "/file", "GET", func(req *resty.Request) {
|
||||||
|
req.SetQueryParams(map[string]string{
|
||||||
|
"method": "streaming",
|
||||||
|
"group_by": "source",
|
||||||
|
"fid": file.GetID(),
|
||||||
|
"resolution": "low,normal,high,super,2k,4k",
|
||||||
|
"support": "dolby_vision",
|
||||||
|
})
|
||||||
|
}, &fileLink)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &model.Link{
|
||||||
|
URL: fileLink.Data.VideoInfo[0].URL,
|
||||||
|
Concurrency: 3,
|
||||||
|
PartSize: 10 * utils.MB,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *QuarkUCTV) getDownloadLink(ctx context.Context, file model.Obj) (*model.Link, error) {
|
||||||
|
var fileLink DownloadFileLink
|
||||||
|
_, err := d.request(ctx, "/file", "GET", func(req *resty.Request) {
|
||||||
|
req.SetQueryParams(map[string]string{
|
||||||
|
"method": "download",
|
||||||
|
"group_by": "source",
|
||||||
|
"fid": file.GetID(),
|
||||||
|
"resolution": "low,normal,high,super,2k,4k",
|
||||||
|
"support": "dolby_vision",
|
||||||
|
})
|
||||||
|
}, &fileLink)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &model.Link{
|
||||||
|
URL: fileLink.Data.DownloadURL,
|
||||||
|
Concurrency: 3,
|
||||||
|
PartSize: 10 * utils.MB,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user