Skip to content

Commit

Permalink
v3.7.7
Browse files Browse the repository at this point in the history
  • Loading branch information
qjfoidnh committed Mar 11, 2021
1 parent dcbc9a8 commit 8a8540c
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 13 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ iikira/BaiduPCS-Go was largely inspired by [GangZhuo/BaiduPCS](https://github.co
[离线下载](#离线下载), 支持http/https/ftp/电驴/磁力链协议.

# 版本更新
**2021.2.23** v3.7.7:

- fix 移动和重命名文件时末尾```/```导致报错
- fix 3.7.2版本后在线升级无效
- fix 转存误报缺少STOKEN

**2021.2.23** v3.7.6:

Expand Down
16 changes: 16 additions & 0 deletions baidupcs/baidupcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,22 @@ func (pcs *BaiduPCS) SetStoken(stoken string) {
})
}

// SetSboxtkn 设置sboxtkn
func (pcs *BaiduPCS) SetSboxtkn(sboxtkn string) {
pcs.lazyInit()
if pcs.client.Jar == nil {
pcs.client.ResetCookiejar()
}

pcs.client.Jar.SetCookies(baiduComURL, []*http.Cookie{
&http.Cookie{
Name: "SBOXTKN",
Value: sboxtkn,
Domain: DotBaiduCom,
},
})
}

// SetPCSUserAgent 设置 PCS User-Agent
func (pcs *BaiduPCS) SetPCSUserAgent(ua string) {
pcs.pcsUA = ua
Expand Down
11 changes: 6 additions & 5 deletions baidupcs/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,15 @@ func (pcs *BaiduPCS) ExtractShareInfo(metajsonstr string) (res map[string]string
res["ErrMsg"] = "提取码错误"
return
}
res["filename"] = gjson.Get(metajsonstr, `file_list.list.0.server_filename`).String()
fsid_list := gjson.Get(metajsonstr, `file_list.list.#.fs_id`).Array()
res["item_num"] = strconv.Itoa(len(fsid_list))
res["filename"] = gjson.Get(metajsonstr, `file_list.0.server_filename`).String()
fsid_list := gjson.Get(metajsonstr, `file_list.#.fs_id`).Array()
var fids_str string = "["
for _, sid := range fsid_list {
fids_str += sid.String() + ","
}

res["shareid"] = gjson.Get(metajsonstr, `shareid`).String()
res["from"] = gjson.Get(metajsonstr, `uk`).String()
res["from"] = gjson.Get(metajsonstr, `share_uk`).String()
res["bdstoken"] = gjson.Get(metajsonstr, `bdstoken`).String()
shareUrl := &url.URL{
Scheme: GetHTTPScheme(true),
Expand All @@ -76,6 +75,7 @@ func (pcs *BaiduPCS) ExtractShareInfo(metajsonstr string) (res map[string]string
for key, value := range res {
uv.Set(key, value)
}
res["item_num"] = strconv.Itoa(len(fsid_list))
res["ErrMsg"] = "0"
res["fs_id"] = fids_str[:len(fids_str)-1] + "]"
shareUrl.RawQuery = uv.Encode()
Expand Down Expand Up @@ -134,13 +134,14 @@ func (pcs *BaiduPCS) AccessSharePage(featurestr string, first bool) (tokens map[
tokens["ErrMsg"] = "分享链接已失效"
return
} else {
re, _ := regexp.Compile(`yunData\.setData\((\{"loginstate.+?\})\);`)
re, _ := regexp.Compile(`(\{.+?loginstate.+?\})\);`)
sub := re.FindSubmatch(body)
if len(sub) < 2 {
tokens["ErrMsg"] = "请确认登录参数中已经包含了网盘STOKEN"
return
}
tokens["metajson"] = string(sub[1])
tokens["bdstoken"] = gjson.Get(string(sub[1]), `bdstoken`).String()
return
}

Expand Down
4 changes: 2 additions & 2 deletions internal/pcscommand/cp_mv.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func runCpMvOp(op string, paths ...string) {
pcs := GetBaiduPCS()
toInfo, pcsError := pcs.FilesDirectoriesMeta(to)
switch {
case toInfo != nil && toInfo.Path != to:
case toInfo != nil && toInfo.Path != path.Clean(to):
fallthrough
case pcsError != nil && pcsError.GetErrType() == pcserror.ErrTypeRemoteError:
// 判断路径是否存在
Expand All @@ -78,7 +78,7 @@ func runCpMvOp(op string, paths ...string) {
fmt.Println("文件/目录拷贝成功: ")
fmt.Printf("%s <-> %s\n", froms[0], to)
} else { // 重命名
err = pcs.Rename(froms[0], to)
err = pcs.Rename(froms[0], path.Clean(to))
if err != nil {
fmt.Println(err)
fmt.Println("重命名失败: ")
Expand Down
4 changes: 4 additions & 0 deletions internal/pcsconfig/baidu.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Baidu struct {
BDUSS string `json:"bduss"`
PTOKEN string `json:"ptoken"`
STOKEN string `json:"stoken"`
SBOXTKN string `json:"sboxtkn"`
COOKIES string `json:"cookies"`

Workdir string `json:"workdir"` // 工作目录
Expand All @@ -46,6 +47,9 @@ type Baidu struct {
func (baidu *Baidu) BaiduPCS() *baidupcs.BaiduPCS {
pcs := baidupcs.NewPCS(Config.AppID, baidu.BDUSS)
pcs.SetStoken(baidu.STOKEN)
if baidu.SBOXTKN != "" {
pcs.SetSboxtkn(baidu.SBOXTKN)
}
if strings.Contains(baidu.COOKIES, "STOKEN=") && baidu.STOKEN == "" {
// 未显式指定stoken则从cookies中读取
pcs = baidupcs.NewPCSWithCookieStr(Config.AppID, baidu.COOKIES)
Expand Down
2 changes: 1 addition & 1 deletion internal/pcsconfig/maniper.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (c *PCSConfig) SetupUserByBDUSS(bduss, ptoken, stoken, cookies string) (bai
UID: b.UID,
}) // 删除旧的信息

b.PTOKEN = ptoken
b.PTOKEN = ptoken // 实际未使用
b.STOKEN = stoken
b.COOKIES = cookies

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const (

var (
// Version 版本号
Version = "v3.7.6-devel"
Version = "v3.7.7-devel"

historyFilePath = filepath.Join(pcsconfig.GetConfigDir(), "pcs_command_history.txt")
reloadFn = func(c *cli.Context) error {
Expand Down
8 changes: 4 additions & 4 deletions versioninfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"FileVersion": {
"Major": 3,
"Minor": 7,
"Patch": 5,
"Patch": 7,
"Build": 0
},
"ProductVersion": {
"Major": 3,
"Minor": 7,
"Patch": 5,
"Patch": 7,
"Build": 0
},
"FileFlagsMask": "3f",
Expand All @@ -22,14 +22,14 @@
"Comments": "",
"CompanyName": "qjfoidnh",
"FileDescription": "百度网盘客户端(加强版)",
"FileVersion": "v3.7.5",
"FileVersion": "v3.7.7",
"InternalName": "",
"LegalCopyright": "© 2016-2020 iikira.",
"LegalTrademarks": "",
"OriginalFilename": "",
"PrivateBuild": "",
"ProductName": "BaiduPCS-Go",
"ProductVersion": "v3.7.5",
"ProductVersion": "v3.7.7",
"SpecialBuild": ""
},
"VarFileInfo": {
Expand Down

0 comments on commit 8a8540c

Please sign in to comment.