Skip to content

Commit

Permalink
Update util.go
Browse files Browse the repository at this point in the history
zengge99 authored Jun 17, 2024
1 parent f459d0e commit d7a44ca
Showing 1 changed file with 1 addition and 98 deletions.
99 changes: 1 addition & 98 deletions drivers/quark_share/util.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ import (
"strconv"
"strings"
"time"
"math/rand"

"github.com/alist-org/alist/v3/drivers/base"
"github.com/alist-org/alist/v3/internal/model"
@@ -102,7 +101,7 @@ func (d *QuarkShare) getStoken() (string) {
}
data := base.Json{
"pwd_id": d.Addition.ShareId,
"passcode": "",
"passcode": d.Addition.PassCode,
}
rsp, _ := d.request("/share/sharepage/token", http.MethodPost, func(req *resty.Request) {
req.SetQueryParams(query)
@@ -132,102 +131,6 @@ func (d *QuarkShare) upPre(file model.FileStreamer, parentId string) (UpPreResp,
return resp, err
}

func (d *QuarkShare) save(file model.Obj) (string) {
data := base.Json{
"fid_list": []string{file.GetID()},
"fid_token_list": []string{file.(*Object).FidToken},
"to_pdir_fid": "0",
"pwd_id": d.Addition.ShareId,
"stoken": d.stoken,
"pdir_fid": "0",
"scene": "link",
}
query := map[string]string{
"uc_param_str": "",
"__dt": strconv.FormatInt(int64(rand.Float64()*(5-1)+1) * 60 * 1000, 10),
"__t": strconv.FormatInt(time.Now().UnixNano()/1000000, 10),
}
rsp, _ := d.request("/share/sharepage/save", http.MethodPost, func(req *resty.Request) {
req.SetQueryParams(query)
req.SetBody(data)
}, nil)
taskId := utils.Json.Get(rsp, "data", "task_id").ToString()

retry := int64(0)
query = map[string]string{
"uc_param_str": "",
"task_id": taskId,
"__dt": strconv.FormatInt(int64(rand.Float64()*(5-1)+1) * 60 * 1000, 10),
"__t": strconv.FormatInt(time.Now().UnixNano()/1000000, 10),
}
for {
query["retry_index"] = strconv.FormatInt(retry, 10)
var taskResp TaskResp
d.request("/task", http.MethodGet, func(req *resty.Request) {
req.SetQueryParams(query)
}, &taskResp)
fid := ""
if(len(taskResp.Data.SaveAsData.FidList) > 0) {
fid = taskResp.Data.SaveAsData.FidList[0]
}
if fid != "" {
fmt.Println("转存文件成功:", fid, file.GetName())
return fid
}
time.Sleep(2 * time.Second)
retry++
if retry > 3 {
break
}
}
fmt.Println("转存文件失败:", file.GetName())
return ""
}

func (d *QuarkShare) delete(fid string) {
data := base.Json{
"action_type": 2,
"filelist": []string{fid},
"exclude_fids": []string{},
}
query := map[string]string{
"uc_param_str": "",
}
d.request("/file/delete", http.MethodPost, func(req *resty.Request) {
req.SetQueryParams(query)
req.SetBody(data)
}, nil)
}

func (d *QuarkShare) link(file model.Obj, fid string) (*model.Link, error) {
data := base.Json{
"fids": []string{fid},
}
var resp DownResp
ua := d.conf.ua
_, err := d.request("/file/download", http.MethodPost, func(req *resty.Request) {
req.SetHeader("User-Agent", ua).
SetBody(data)
}, &resp)
if err != nil {
fmt.Println("获取夸克直链失败", file.GetName(), err)
return nil, err
}

fmt.Println("获取夸克直链成功:", file.GetName(), resp.Data[0].DownloadUrl)

return &model.Link{
URL: resp.Data[0].DownloadUrl,
Header: http.Header{
"Cookie": []string{d.Cookie},
"Referer": []string{d.conf.referer},
"User-Agent": []string{ua},
},
//Concurrency: 2,
//PartSize: 10 * utils.MB,
}, nil
}

func (d *QuarkShare) upHash(md5, sha1, taskId string) (bool, error) {
data := base.Json{
"md5": md5,

0 comments on commit d7a44ca

Please sign in to comment.