Skip to content

Commit

Permalink
v3.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
iikira committed May 16, 2018
1 parent 62fa3b3 commit d1e936d
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 61 deletions.
13 changes: 8 additions & 5 deletions .github/RELEASE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# 更新日志:

1. 修复 bug;
2. 支持检测更新;
3. 列目录支持排序选项;
4. 调整配置文件储存目录, 可选家目录和程序所在目录;
5. emm...
1. 修复下载无法断点续传的 bug;
2. 修复程序自动更新失败的 bug;
3. 支持分享/取消分享文件/目录;
4. 支持获取文件下载的直链;
5. 支持以分享文件的方式获取下载链接来下载,和以获取直链的方式来下载;
6. 新增 who 命令, 获取当前帐号;

v3.5.1 的自动更新功能异常, 手动更新吧....

个人项目bug在所难免! 欢迎提 issue 和 pull request!!.

Expand Down
65 changes: 55 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This project was largely inspired by [GangZhuo/BaiduPCS](https://github.com/Gang
* [检测程序更新](#检测程序更新)
* [登录百度帐号](#登录百度帐号)
* [列出帐号列表](#列出帐号列表)
* [获取当前帐号](#获取当前帐号)
* [切换百度帐号](#切换百度帐号)
* [退出百度帐号](#退出百度帐号)
* [获取网盘配额](#获取网盘配额)
Expand All @@ -30,13 +31,18 @@ This project was largely inspired by [GangZhuo/BaiduPCS](https://github.com/Gang
* [获取单个文件/目录的元信息](#获取单个文件目录的元信息)
* [下载文件/目录](#下载文件目录)
* [上传文件/目录](#上传文件目录)
* [获取下载直链](#获取下载直链)
* [手动秒传文件](#手动秒传文件)
* [获取本地文件的秒传信息](#获取本地文件的秒传信息)
* [导出文件/目录](#导出文件目录)
* [创建目录](#创建目录)
* [删除文件/目录](#删除文件目录)
* [拷贝文件/目录](#拷贝文件目录)
* [移动/重命名文件/目录](#移动重命名文件目录)
* [分享文件/目录](#分享文件目录)
+ [设置分享文件/目录](#设置分享文件目录)
+ [列出已分享文件/目录](#列出已分享文件目录)
+ [取消分享文件/目录](#取消分享文件目录)
* [离线下载](#离线下载)
+ [添加离线下载任务](#添加离线下载任务)
+ [精确查询离线下载任务](#精确查询离线下载任务)
Expand Down Expand Up @@ -164,7 +170,13 @@ BaiduPCS-Go login
BaiduPCS-Go loglist
```

获取当前帐号, 和所有已登录的百度帐号
列出所有已登录的百度帐号

## 获取当前帐号

```
BaiduPCS-Go who
```

## 切换百度帐号

Expand Down Expand Up @@ -299,12 +311,15 @@ BaiduPCS-Go d <网盘文件或目录的路径1> <文件或目录2> <文件或目

### 可选参数
```
-test: 测试下载, 此操作不会保存文件到本地
-status: 输出所有线程的工作状态
--save: 将下载的文件直接保存到当前工作目录
--saveto: 将下载的文件直接保存到指定的目录
-x: 为文件加上执行权限, (windows系统无效)
-p <num>: 指定下载的最大并发量
--test 测试下载, 此操作不会保存文件到本地
--ow overwrite, 覆盖已存在的文件
--status 输出所有线程的工作状态
--save 将下载的文件直接保存到当前工作目录
--saveto value 将下载的文件直接保存到指定的目录
-x 为文件加上执行权限, (windows系统无效)
--share 以分享文件的方式获取下载链接来下载
--locate 以获取直链的方式来下载
-p value 指定下载线程数
```

支持多个文件或目录的下载.
Expand Down Expand Up @@ -355,6 +370,11 @@ BaiduPCS-Go upload C:/Users/Administrator/Desktop/1.mp4 C:/Users/Administrator/D
BaiduPCS-Go upload C:/Users/Administrator/Desktop /视频
```

## 获取下载直链
```
BaiduPCS-Go locate <文件1> <文件2> ...
```

## 手动秒传文件
```
BaiduPCS-Go rapidupload -length=<文件的大小> -md5=<文件的md5值> -slicemd5=<文件前256KB切片的md5值(可选)> -crc32=<文件的crc32值(可选)> <保存的网盘路径, 需包含文件名>
Expand Down Expand Up @@ -403,10 +423,10 @@ BaiduPCS-Go ep <文件/目录1> <文件/目录2> ...
# 导出当前工作目录:
BaiduPCS-Go export
# 导出所有文件和目录, 并设置新的根目录为 `/root`
# 导出所有文件和目录, 并设置新的根目录为 /root
BaiduPCS-Go export -root=/root /
# 导出 `/我的资源`
# 导出 /我的资源
BaiduPCS-Go export /我的资源
```

Expand Down Expand Up @@ -480,6 +500,31 @@ BaiduPCS-Go mv /我的资源/1.mp4 /
BaiduPCS-Go mv /我的资源/1.mp4 /我的资源/3.mp4
```

## 分享文件/目录
```
BaiduPCS-Go share
```

### 设置分享文件/目录
```
BaiduPCS-Go share set <文件/目录1> <文件/目录2> ...
BaiduPCS-Go share s <文件/目录1> <文件/目录2> ...
```

### 列出已分享文件/目录
```
BaiduPCS-Go share list
BaiduPCS-Go share l
```

### 取消分享文件/目录
```
BaiduPCS-Go share cancel <shareid_1> <shareid_2> ...
BaiduPCS-Go share c <shareid_1> <shareid_2> ...
```

目前只支持通过分享id (shareid) 来取消分享.

## 离线下载
```
BaiduPCS-Go offlinedl
Expand Down Expand Up @@ -695,4 +740,4 @@ QQ群: 178324706

|支付宝|
|:-----:|
|![alipay](./assets/donate/alipay.jpg)|
|![alipay](https://github.com/iikira/BaiduPCS-Go/raw/master/assets/donate/alipay.jpg)|
14 changes: 0 additions & 14 deletions baidupcs/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/iikira/baidu-tools/pan"
"github.com/json-iterator/go"
"net/url"
"path"
"strconv"
"strings"
)
Expand Down Expand Up @@ -48,26 +47,13 @@ type ShareRecordInfoList []*ShareRecordInfo

// Clean 清理
func (sril *ShareRecordInfoList) Clean() {
newSril := make(ShareRecordInfoList, 0, len(*sril))

for _, sri := range *sril {
if sri == nil {
continue
}

if !path.IsAbs(sri.TypicalPath) {
continue
}

if len(sri.FsIds) == 0 {
continue
}

sri.Clean()
newSril = append(newSril, sri)
}

*sril = newSril
}

// ShareSet 分享文件
Expand Down
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name="BaiduPCS-Go"
version=$1

if [ "$1" = "" ];then
version=v3.5.1
version=v3.5.2
fi

output="out/"
Expand All @@ -19,10 +19,10 @@ Build() {
export GOOS=$2 GOARCH=$3 GO386=sse2 CGO_ENABLED=0 GOARM=$4
if [ $2 = "windows" ];then
goversioninfo -icon=assets/$name.ico -manifest="$name".exe.manifest -product-name="$name" -file-version="$version" -product-version="$version" -company=iikira -copyright="© 2016-2018 iikira." -o=resource_windows.syso
go build -ldflags "-s -w" -o "$output/$1/$name.exe"
go build -ldflags "-X main.Version=$version -s -w" -o "$output/$1/$name.exe"
RicePack $1 $name.exe
else
go build -ldflags "-s -w" -o "$output/$1/$name"
go build -ldflags "-X main.Version=$version -s -w" -o "$output/$1/$name"
RicePack $1 $name
fi

Expand All @@ -32,7 +32,7 @@ Build() {
ArmBuild() {
echo "Building $1..."
export GOOS=$2 GOARCH=$3 GOARM=$4 CGO_ENABLED=1
go build -ldflags '-s -w -linkmode=external -extldflags=-pie' -o "$output/$1/$name"
go build -ldflags "-X main.Version=$version -s -w -linkmode=external -extldflags=-pie" -o "$output/$1/$name"
if [ $2 = "darwin" ] && [ $3 = "arm" -o $3 = "arm64" ];then
# cp Info.plist "$output/$1"
ldid -S "$output/$1/$name"
Expand Down
2 changes: 1 addition & 1 deletion debian/iphoneos-arm/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: BaiduPCS-Go
Version: 3.5.1
Version: 3.5.2
Homepage: https://github.com/iikira/BaiduPCS-Go
Section: 实用工具
Priority: optional
Expand Down
19 changes: 16 additions & 3 deletions internal/pcscommand/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/iikira/BaiduPCS-Go/pcstable"
"github.com/iikira/BaiduPCS-Go/requester"
"github.com/iikira/baidu-tools/pan"
"net/url"
"os"
"path"
"strconv"
Expand Down Expand Up @@ -55,13 +56,13 @@ func RunShareList() {
}

tb := pcstable.NewTable(os.Stdout)
tb.SetHeader([]string{"#", "ShareID", "分享链接", "提取密码", "根目录"})
tb.SetHeader([]string{"#", "ShareID", "分享链接", "提取密码", "根目录", "路径"})
for k, record := range records {
if record == nil {
continue
}

tb.Append([]string{strconv.Itoa(k), strconv.FormatInt(record.ShareID, 10), record.Shortlink, record.Passwd, path.Dir(record.TypicalPath)})
tb.Append([]string{strconv.Itoa(k), strconv.FormatInt(record.ShareID, 10), record.Shortlink, record.Passwd, record.TypicalPath[:strings.LastIndex(record.TypicalPath, "/")+1], record.TypicalPath})
}
tb.Render()
}
Expand Down Expand Up @@ -155,5 +156,17 @@ func getLink(shareID int64, shareLink, passwd, rootSharePath, filePath string) (
return ""
}

return fd.Dlink
u, err := url.Parse(fd.Dlink)
if err != nil {
pcsCommandVerbose.Warn(err.Error())
return ""
}

if pcsconfig.Config.EnableHTTPS() {
u.Scheme = "https"
} else {
u.Scheme = "http"
}

return u.String()
}
6 changes: 3 additions & 3 deletions internal/pcsupdate/pcsupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func CheckUpdate(version string, yes bool) {
continue
}

// 忽略 Beta 版本
if strings.Contains(versionInfo.Filename, "Beta") {
// 忽略 Beta 版本, 和版本前缀不符的
if strings.Contains(versionInfo.Filename, "Beta") || !strings.HasPrefix(versionInfo.Filename, "v") {
continue
}

Expand Down Expand Up @@ -139,7 +139,7 @@ func CheckUpdate(version string, yes bool) {
continue
}

if fileInfo.Isdir == 1 || !strings.HasPrefix(fileInfo.Filename, "v") {
if fileInfo.Isdir == 1 {
continue
}

Expand Down
47 changes: 30 additions & 17 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

var (
// Version 版本号
Version = "v3.5.1"
Version = "v3.5.2-devel"

historyFilePath = filepath.Join(pcsconfig.GetConfigDir(), "pcs_command_history.txt")
reloadFn = func(c *cli.Context) error {
Expand Down Expand Up @@ -125,7 +125,7 @@ func main() {
fmt.Printf("未找到命令: %s\n运行命令 %s help 获取帮助\n", c.Args().Get(0), app.Name)
return
}
cli.ShowAppHelp(c)

pcsverbose.Verbosef("VERBOSE: 这是一条调试信息\n\n")

var (
Expand Down Expand Up @@ -271,6 +271,8 @@ func main() {
return
})

fmt.Printf("提示: 输入 help 获取帮助.\n")

for {
var (
prompt string
Expand Down Expand Up @@ -580,18 +582,27 @@ func main() {
{
Name: "loglist",
Usage: "列出帐号列表",
Description: "获取当前帐号, 和所有已登录的百度帐号",
Description: "列出所有已登录的百度帐号",
Category: "百度帐号",
Before: reloadFn,
Action: func(c *cli.Context) error {
activeUser := pcsconfig.Config.ActiveUser()
fmt.Printf("\n当前帐号 uid: %d, 用户名: %s\n\n", activeUser.UID, activeUser.Name)

list := pcsconfig.Config.BaiduUserList()
fmt.Println(list.String())
return nil
},
},
{
Name: "who",
Usage: "获取当前帐号",
Description: "获取当前帐号的信息",
Category: "百度帐号",
Before: reloadFn,
Action: func(c *cli.Context) error {
activeUser := pcsconfig.Config.ActiveUser()
fmt.Printf("当前帐号 uid: %d, 用户名: %s, 性别: %s, 年龄: %.1f\n", activeUser.UID, activeUser.Name, activeUser.Sex, activeUser.Age)
return nil
},
},
{
Name: "quota",
Usage: "获取网盘配额",
Expand Down Expand Up @@ -1004,7 +1015,7 @@ func main() {
Name: "locate",
Aliases: []string{"lt"},
Usage: "获取下载直链",
UsageText: fmt.Sprintf("%s locate <文件>", app.Name),
UsageText: fmt.Sprintf("%s locate <文件1> <文件2> ...", app.Name),
Category: "百度网盘",
Before: reloadFn,
Action: func(c *cli.Context) error {
Expand Down Expand Up @@ -1154,7 +1165,7 @@ func main() {
},
{
Name: "share",
Usage: "分享文件",
Usage: "分享文件/目录",
UsageText: app.Name + " share",
Category: "百度网盘",
Before: reloadFn,
Expand All @@ -1167,10 +1178,11 @@ func main() {
},
Subcommands: []cli.Command{
{
Name: "set",
Aliases: []string{"s"},
Usage: "设置分享文件",
UsageText: app.Name + " share set <文件/目录1> <文件/目录2> ...",
Name: "set",
Aliases: []string{"s"},
Usage: "设置分享文件/目录",
UsageText: app.Name + " share set <文件/目录1> <文件/目录2> ...",
Description: `目前只支持创建私密链接.`,
Action: func(c *cli.Context) error {
if c.NArg() < 1 {
cli.ShowCommandHelp(c, c.Command.Name)
Expand All @@ -1183,18 +1195,19 @@ func main() {
{
Name: "list",
Aliases: []string{"l"},
Usage: "列出已分享文件",
Usage: "列出已分享文件/目录",
UsageText: app.Name + " share list",
Action: func(c *cli.Context) error {
pcscommand.RunShareList()
return nil
},
},
{
Name: "cancel",
Aliases: []string{"c"},
Usage: "取消分享文件",
UsageText: app.Name + " share cancel <shareid1> <shareid2> ...",
Name: "cancel",
Aliases: []string{"c"},
Usage: "取消分享文件/目录",
UsageText: app.Name + " share cancel <shareid_1> <shareid_2> ...",
Description: `目前只支持通过分享id (shareid) 来取消分享.`,
Action: func(c *cli.Context) error {
if c.NArg() < 1 {
cli.ShowCommandHelp(c, c.Command.Name)
Expand Down
Binary file modified resource_windows.syso
Binary file not shown.
Loading

0 comments on commit d1e936d

Please sign in to comment.