diff --git a/README.md b/README.md index 41dfbd8..8f6a056 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/baidupcs/baidupcs.go b/baidupcs/baidupcs.go index d558f52..00d4bf4 100644 --- a/baidupcs/baidupcs.go +++ b/baidupcs/baidupcs.go @@ -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 diff --git a/baidupcs/transfer.go b/baidupcs/transfer.go index ebc5993..ebbb9b4 100644 --- a/baidupcs/transfer.go +++ b/baidupcs/transfer.go @@ -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), @@ -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() @@ -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 } diff --git a/internal/pcscommand/cp_mv.go b/internal/pcscommand/cp_mv.go index 7abcce3..7326b14 100644 --- a/internal/pcscommand/cp_mv.go +++ b/internal/pcscommand/cp_mv.go @@ -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: // 判断路径是否存在 @@ -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("重命名失败: ") diff --git a/internal/pcsconfig/baidu.go b/internal/pcsconfig/baidu.go index d1818e9..dd098c1 100644 --- a/internal/pcsconfig/baidu.go +++ b/internal/pcsconfig/baidu.go @@ -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"` // 工作目录 @@ -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) diff --git a/internal/pcsconfig/maniper.go b/internal/pcsconfig/maniper.go index cee6517..e7c0b88 100644 --- a/internal/pcsconfig/maniper.go +++ b/internal/pcsconfig/maniper.go @@ -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 diff --git a/main.go b/main.go index ea755d8..a17ef66 100644 --- a/main.go +++ b/main.go @@ -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 { diff --git a/versioninfo.json b/versioninfo.json index e038ff5..d1ec18c 100644 --- a/versioninfo.json +++ b/versioninfo.json @@ -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", @@ -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": {