简单说明:
- 由于百度 PCS API 权限限制,bypy 只能存取百度云端/apps/bypy目录下面的文件和目录
- bypy 没有提速效果,想要下载不限速,需要自行购买 SVIP
构建镜像之前老苏写过 『 Docker中运行百度网盘客户端 』,那是带图形界面的官方客户端,而 bypy 则是第三方的命令行工具
如果你不想自己构建,可以跳过,直接阅读下一章节
bypy 官方没有提供 Dockerfile 或者镜像,但第三方的还是很多的,只是都有些年代久远,所以老苏还是准备自己构建
- v1 版 Dockerfile
FROM python:3.6-slim MAINTAINER laosuWORKDIR /baidupy COPY . /baidupy/ # Environment ENV TERM=xterm RUN pip install bypy # Application EXPOSE 80 ENV NAME Python_client_for_Baidu_Yun CMD bypy info
但是老苏发现 v1 版的容器停止后会无法启动,因为 bypy info 在获取到云盘容量后会退出,导致 exited with code 0,因此老苏引入了 Supervisor 来做进程管理
- v2 版 Dockerfile
FROM python:3.6-slim MAINTAINER laosuWORKDIR /baidupy # Application RUN apt-get update -y && apt-get install -y supervisor RUN pip install bypy # supervisord COPY supervisord.conf /etc/supervisord.conf # Environment ENV TERM=xterm ENV NAME=Python_client_for_Baidu_Yun #定义时区参数(非必须) ENV TZ=Asia/Shanghai #设置时区(非必须) RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone #设置编码(非必须) ENV LANG C.UTF-8 ENTRYPOINT ["supervisord","-c","/etc/supervisord.conf"]
v2 版除了 Dockerfile,还需要准备 supervisord.conf 文件
[include] files = /etc/supervisor/conf.d/*.conf [program:bypy] command=bypy info #directory will be any folder where you wnat supervisor to cd before executing. #directory=/project autostart=true autorestart=false startretries=3 #user will be anyone you want but make sure that user will have the enough privilage. user=root [supervisord] nodaemon=true logfile=/tmp/supervisord.log pidfile=/tmp/supervisord.pid loglevel=debug logfile_maxbytes=10MB [supervisorctl]
构建镜像和容器运行的基本命令如下
# 将 Dockerfile 和 supervisord.conf 放在同一个目录 # 构建镜像 docker build -t wbsu2003/bypy:v2 . # 生成容器 docker run -it --name=bypy -v /volume2/docker/bypy:/baidupy wbsu2003/bypy:v2 # 运行容器 docker start bypy # 进入容器 docker exec --user root -it bypy /bin/sh # 退出容器 exit 或者 ctrl+D安装
在群晖上以 Docker 方式安装。
在注册表中搜索 wbsu2003 ,找到 wbsu2003/bypy,版本选择 latest。
卷在 docker 文件夹中,创建一个新文件夹,并将其命名为 bypy
| 文件夹 | 装载路径 | 说明 |
|---|---|---|
| docker/bypy | /baidupy | 文件存放目录 |
和 cloud189-cli 一样,bypy 也是命令行方式的,所以要么在 SSH 客户端上运行,要么进 『终端机』 运行。
老苏建议还是在 SSH 客户端上运行比较方便,关于 cloud189-cli 请看:『在群晖上使用天翼云盘』
终端机 --> 新增 --> 通过命令启动 --> bash
第一次需要授权,执行 bypy info,然后复制红框部分的内容,在浏览器中打开
复制生成的授权码
粘贴到红框位置,然后回车
程序会利用不同的服务器进行认证,认证成功会显示百度网盘的容量,如果一次没成功,可以多试几次。
过程有点长,而且失败的概率还挺高的,要有耐心~~~
有的网站直接报错
有的访问不到
极端情况下会认证失败,只能重新再来一遍了,因为这个授权码有时间限制
认证成功后,会显示空间的大小
授权只需一次,一旦成功,以后就不会再出现授权提示
常用命令 帮助access_token 和 refresh_token 保存在 /~/.bypy/bypy.json 中
执行 bypy 或者 bypy help
更详细的可以运行
bypy help
例如: bypy help list
文件列表执行 bypy list 可以列出云盘的文件
在百度盘中的 /apps/bypy目录中
下载也就是将云盘内容同步到本地,可以执行 bypy syncdown 或者 bypy downdir /,不是会员的话,下载速度就比较慢
下载完成后,可以在 File Station 中看到下载的文件
上传也就是将当前目录同步到云盘,可以执行 bypy syncup 或者 bypy upload
先在 File Station 增加一个将近百兆的 exe 文件
上传速度比下载要快一点
同步完成
刷新网盘
比较要比较本地当前目录和云盘(程序的)根目录,可以执行 bypy compare
为啥会 Different:2 ,老苏也没闹明白,很可能是因为下载中断过的缘故
更多命令和详细解释请看运行 bypy 的输出,或者阅读官方的文档。
参考文档houtianze/bypy: Python client for Baidu Yun (Personal Cloud Storage) 百度云/百度网盘Python客户端
地址:https://github.com/houtianze/bypy/
bypy-百度网盘Python客户端 linux - 简书
地址:https://www.jianshu.com/p/c9467daf701f/
exited with code 0 docker - Stack Overflow
地址:https://stackoverflow.com/questions/44884719/exited-with-code-0-docker
Understanding Docker Container Exit Codes | by Sandeep Madamanchi | Better Programming
地址:https://betterprogramming.pub/understanding-docker-container-exit-codes-5ee79a1d58f6



