Ubuntu:百度网盘 Python 客户端的使用
时间:2016-05-17 11:59 来源:linux.it.net.cn 作者:IT
百度云官方没有提供 Ubuntu 的客户端,之前一直使用百度云网页版进行操作,但网页版只能上传文件,不能上传文件目录,非常不方便,听同事推荐,有一款 python 写的 百度云客户端,可以上传文件,于是测试下:
--下载
https://github.com/houtianze/bypy
francs@francs:~/Desktop/byby$ git clone https://github.com/houtianze/bypy byby/
Cloning into 'byby'...
remote: Reusing existing pack: 179, done.
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 182 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (182/182), 142.77 KiB | 33 KiB/s, done.
Resolving deltas: 100% (108/108), done.
--安装 python requests 库
francs@francs:~/Desktop/byby/byby$ sudo pip install requests
Downloading/unpacking requests
Downloading requests-2.2.1.tar.gz (421Kb): 421Kb downloaded
Running setup.py egg_info for package requests
Installing collected packages: requests
Running setup.py install for requests
Successfully installed requests
Cleaning up...
备注:开始执行这步时报错,翻墙后执行正常,执行完后还有个百度的网页进行授权过程,根据提示点击链接,之后复制授权码即可。
--同步本地目录到百度云
francs@francs:/media/work/byby/byby$ python bypy.py syncup /media/work/娱乐//fc500game.exe
备注:这样就可以同步文件夹了。
--列出远程根目录文件
francs@francs:/media/work/byby/byby$ python bypy.py list
Token file: '/home/francs/.bypy.json'
Hash Cache file: '/home/francs/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8
sys.stdout.encoding = UTF-8
----
/apps/bypy ($t $f $s $m $d):
D fc500game 0 2014-04-02, 16:36:13
--列出远程 /apps/bypy/fc500game 文件
francs@francs:/media/work/byby/byby$ python bypy.py list /fc500game
Token file: '/home/francs/.bypy.json'
Hash Cache file: '/home/francs/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8
sys.stdout.encoding = UTF-8
----
/apps/bypy/fc500game ($t $f $s $m $d):
D rom 0 2014-04-02, 16:36:18
F aq7z.dll 96256 2014-04-02, 16:36:18 53014f3764238d08a48590e2e1f5f4b9
F nnnesterJ.exe 770048 2014-04-02, 16:36:15 c350676fe0e7ae08bc9e3fafb0eb8284
F PlayGame.exe 2490384 2014-04-02, 16:36:17 487c986d2a7bdac4e4c859ee3cef625c
--比较远程目录和本地目录
python bypy.py compare /fc500game /media/work/娱乐/fc500game
==== Same files ===
....省略
...
==== Different files ===
F - rom/洛克人X.zip
F - rom/地道战(中文)/ddz.zip
F - rom/血之战士.zip
==== Local only ====
==== Remote only ====
Statistics:
--------------------------------
Same: 915
Different: 3
Local only: 0
Remote only: 0
备注: compare 命令很有用 ,上面看到不同的文件有 3 个,重新 syncup 一次就一样了。
--附: 常用命令
显示使用帮助和所有命令(英文):
bypy.py
更详细的了解某一个命令:
bypy.py help <command>
显示在云盘(程序的)根目录下文件列表:
bypy.py list
把当前目录同步到云盘:
bypy.py syncup
or
bypy.py upload
把云盘内容同步到本地来:
bypy.py syncdown
or
bypy.py downdir /
比较本地当前目录和云盘(程序的)根目录(个人认为非常有用):
bypy.py compare
还有一些其他命令 ...
哈希值的计算加入了缓存处理,使得第一次以后的计算速度有所提高。
运行时添加 -v 参数,程序会显示进度详情;添加 -d ,程序会显示一些调试信息。
--参考
https://github.com/houtianze/bypy
(责任编辑:IT)
百度云官方没有提供 Ubuntu 的客户端,之前一直使用百度云网页版进行操作,但网页版只能上传文件,不能上传文件目录,非常不方便,听同事推荐,有一款 python 写的 百度云客户端,可以上传文件,于是测试下:
--下载
https://github.com/houtianze/bypy
francs@francs:~/Desktop/byby$ git clone https://github.com/houtianze/bypy byby/
Cloning into 'byby'...
remote: Reusing existing pack: 179, done.
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 182 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (182/182), 142.77 KiB | 33 KiB/s, done.
Resolving deltas: 100% (108/108), done.
--安装 python requests 库
francs@francs:~/Desktop/byby/byby$ sudo pip install requests
Downloading/unpacking requests
Downloading requests-2.2.1.tar.gz (421Kb): 421Kb downloaded
Running setup.py egg_info for package requests
Installing collected packages: requests
Running setup.py install for requests
Successfully installed requests
Cleaning up...
备注:开始执行这步时报错,翻墙后执行正常,执行完后还有个百度的网页进行授权过程,根据提示点击链接,之后复制授权码即可。
--同步本地目录到百度云
francs@francs:/media/work/byby/byby$ python bypy.py syncup /media/work/娱乐//fc500game.exe
备注:这样就可以同步文件夹了。
--列出远程根目录文件
francs@francs:/media/work/byby/byby$ python bypy.py list
Token file: '/home/francs/.bypy.json'
Hash Cache file: '/home/francs/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8
sys.stdout.encoding = UTF-8
----
/apps/bypy ($t $f $s $m $d):
D fc500game 0 2014-04-02, 16:36:13
--列出远程 /apps/bypy/fc500game 文件
francs@francs:/media/work/byby/byby$ python bypy.py list /fc500game
Token file: '/home/francs/.bypy.json'
Hash Cache file: '/home/francs/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8
sys.stdout.encoding = UTF-8
----
/apps/bypy/fc500game ($t $f $s $m $d):
D rom 0 2014-04-02, 16:36:18
F aq7z.dll 96256 2014-04-02, 16:36:18 53014f3764238d08a48590e2e1f5f4b9
F nnnesterJ.exe 770048 2014-04-02, 16:36:15 c350676fe0e7ae08bc9e3fafb0eb8284
F PlayGame.exe 2490384 2014-04-02, 16:36:17 487c986d2a7bdac4e4c859ee3cef625c
--比较远程目录和本地目录
python bypy.py compare /fc500game /media/work/娱乐/fc500game
==== Same files ===
....省略
...
==== Different files ===
F - rom/洛克人X.zip
F - rom/地道战(中文)/ddz.zip
F - rom/血之战士.zip
==== Local only ====
==== Remote only ====
Statistics:
--------------------------------
Same: 915
Different: 3
Local only: 0
Remote only: 0
备注: compare 命令很有用 ,上面看到不同的文件有 3 个,重新 syncup 一次就一样了。
--附: 常用命令
显示使用帮助和所有命令(英文):
bypy.py
更详细的了解某一个命令:
bypy.py help <command>
显示在云盘(程序的)根目录下文件列表:
bypy.py list
把当前目录同步到云盘:
bypy.py syncup
or
bypy.py upload
把云盘内容同步到本地来:
bypy.py syncdown
or
bypy.py downdir /
比较本地当前目录和云盘(程序的)根目录(个人认为非常有用):
bypy.py compare
还有一些其他命令 ...
哈希值的计算加入了缓存处理,使得第一次以后的计算速度有所提高。
运行时添加 -v 参数,程序会显示进度详情;添加 -d ,程序会显示一些调试信息。
--参考
https://github.com/houtianze/bypy
(责任编辑:IT) |