GithubHelp home page GithubHelp logo

gangzhuo / baidupcs Goto Github PK

View Code? Open in Web Editor NEW
3.5K 215.0 723.0 1.59 MB

百度网盘命令行工具。The terminal utility for Baidu Network Disk.

License: Other

C 25.42% Makefile 3.46% Roff 53.65% Shell 16.20% M4 1.27%

baidupcs's Introduction

C/C++写的一个百度网盘工具,可以在linux终端中使用。 这是通过分析网盘网站得到的直接接口,不需要创建应用。

  • 支持多线程下载和下载时断点续传。
  • 支持快速上传和多线程分片上传。
  • 支持线程限速。具体查看'pcs set'和'pcs context'命令的说明。
  • 支持AES-CBC-128, AES-CBC-192, AES-CBC-256加密。

Build Status

查看 初级使用教程

此项目已停止维护: #299

打包安装 (Debian):

1. 安装编译依赖

apt update
apt install build-essential dh-autoreconf dpkg-dev libssl-dev libcurl4-openssl-dev

2. 获取源代码

git clone https://github.com/GangZhuo/BaiduPCS.git

3. 构建打包

cd BaiduPCS
dpkg-buildpackage -us -uc -i -b

4. 安装

cd ..
sudo apt install ./baidupcs_*.deb

编译 (Debian) (新方法):

程序依赖于 libcurl。

1. 安装依赖

apt-get install build-essential libcurl4-openssl-dev libssl-dev

2. 获取源代码

git clone https://github.com/GangZhuo/BaiduPCS.git

3. 编译源代码

cd BaiduPCS
./configure && make
make install #将安装到/usr/local/bin下

4. 手动安装到其他目录,例如 /usr/bin 下

cp ./baidupcs /usr/bin/

编译 (Debian):

程序依赖于 libcurl。

1. 安装依赖

apt-get install build-essential libcurl4-openssl-dev libssl-dev

2. 获取源代码

git clone https://github.com/GangZhuo/BaiduPCS.git

3. 编译源代码

cd BaiduPCS
make clean -f Makefile.old
make -f Makefile.old
make install -f Makefile.old #将安装到/usr/local/bin下

4. 手动安装到其他目录,例如 /usr/bin 下

cp ./bin/pcs /usr/bin/

编译 (Windows):

1. 获取源代码

git clone https://github.com/GangZhuo/BaiduPCS.git

2. 安装依赖

到 https://github.com/GangZhuo/BaiduPCS/releases/tag/0.2.6 下载需要的依赖包 [deps-win32.zip] 。

下载后,把压缩包解压到 deps 目录。

最终目录结构为:

somedirectory
 |-BaiduPCS
 |  |-deps
 |  |  |-include
 |  |  |  |-curl
 |  |  |  |-openssl
 |  |  |-lib
 |  |  |  |-x64
 |  |  |  |-x86
 |  |-docs
 |  |-openwrt
 |  |-pcs
 |  |-rbtree
 |  |-(etc ...)

3. 编译源代码

使用 Microsoft Visual Studio Community 2015 (Update 3) 打开源码根目录下的 baidupcs.sln,并执行编译操作,
将在 Debug 或 Release 目录下产生 baidupcs.exe 文件。

下载 适用Windows的预编译版本 或 下载 .net4.0 带窗体版本 BaiduCloudDisk for .Net 4.0

编译 (Mac):

1. 获取源代码

git clone https://github.com/GangZhuo/BaiduPCS.git

2. 安装依赖

brew install openssl

3. 编译源代码

cd BaiduPCS
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
autoreconf
./configure LD=/usr/bin/ld OPENSSL_LIBS='-lssl -lcrypto -lz'
make clean
make
make install #将安装到/usr/local/bin下

4. 手动安装到其他目录,例如 /usr/bin 下

cp ./baidupcs /usr/bin/

编译 (Openwrt):

进入 Openwrt SDK 目录,然后执行如下命令:

    pushd package
    git clone https://github.com/GangZhuo/BaiduPCS.git
    popd
    make menuconfig # select Utilities/BaiduPCS
    make V=99 package/BaiduPCS/openwrt/compile

或下载 预编译 ipk for Openwrt ,CPU: ar71xx, brcm71xx, brcm47xx, ramips_24kec

命令列表:

如果出现中文乱码,请检查操作系统的当前编码是否为UTF-8。
命令中涉及到的网盘文件路径,可以是绝对路径,也可以是相对于当前工作目录的相对路径。
例:
    /data/data.txt 即是网盘绝对路径,表示网盘根目录下的data目录中的data.txt文件。
    data.txt 即是相对路径,表示当前工作目录下的data.txt文件。
    当前工作目录可通过 'baidupcs pwd' 命令来查看,当前工作目录可通过 'baidupcs cd'命令切换。
    可通过 'baidupcs help' 查看支持的子命令;可在子命令后加 '-h' 查看子命令帮助,
    也可调用类似于 'baidupcs help <command>' 的命令来查看子命令的帮助。
    例如:
        baidupcs move -h。
        baidupcs help move 此命令等价于上一行的命令

直接显示网盘中文本文件内容

baidupcs cat <file>

示例:
  baidupcs cat note.txt
  baidupcs cat /my/todo.txt

切换工作目录

baidupcs cd <dir>

示例:
  baidupcs cd baidupcs
  baidupcs cd /backup/20140618

复制网盘文件或目录

baidupcs copy <old path> <new path>

示例:
  baidupcs copy data.txt data_20140118.txt

比较异同

baidupcs compare [-cderu] <local path> <remote path>

比较本地文件和远端文件、本地目录和远端目录的异同。
默认选项是'-cdu',即打印出需要上传的文件、
需要下载的文件和无法确定上传下载的文件。

比较规则:
  只通过时间来进行比较。
  I)  如果本地和远端都是文件:
        a) 本地最后修改时间大于网盘文件上传时间,则认为需要上传;
        b) 本地最后修改时间小于网盘文件上传时间,则认为需要下载;
           (此处注意:当一个文件上传到网盘后,其网盘时间肯定比本地最后修改时间大。
             如果此时执行比较的话,则会认为该文件需要从网盘下载。
             下载则没有此问题,因为一个文件下载后,程序会使用
             网盘时间来更新本地文件的最后修改时间。)
  II)  本地存在,网盘不存在,则认为需要上传
  III) 本地不存在,网盘存在,则认为需要下载
  IV)  如果一端是文件,另一端是目录,则认为无法确认是上传还是下载。

选项:
  -c  只打印出无法确定上传或下载的项。
      一般是因为本地是文件,远端是目录,或本地是目录远端是文件
  -d  只打印出需要下载的文件或目录
  -e  只打印相同的文件或目录
  -r  递归比较其子目录
  -u  只打印出需要上传的文件或目录

示例:
   baidupcs compare music music
   baidupcs compare -r ~/music music

显示当前上下文

baidupcs context

上下文包括:
    当前使用的Cookie文件、验证码图片保存路径、
    当前的工作目录、列出目录时分页大小、列出目录时的排序字段、
    列出目录时的排序方向、启用的加密方法、加密密钥、是否启用加密

程序开启时会自动读取上下文文件;结束时,会自动保存上下文到文件。
可通过'PCS_CONTEXT'环境变量指定上下文文件路径。程序判断规则是:
   1) 如果通过'--context'选项指定了上下文文件,则使用它;
   2) 如果未通过'--context'指定,但是指定了环境变量'PCS_CONTEXT'则使用它;
   3) 如果也未指定环境变量'PCS_CONTEXT'则使用'~/.pcs/pcs.context'

上下文为JSON格式的文件:

{
    "cookiefile":	        "/home/gang/.pcs/default.cookie", /*指定Cookie文件*/
    "captchafile":	        "/home/gang/.pcs/captcha.gif",    /*指定验证码图片保存路径*/
    "workdir":	            "/",                              /*指定当前的网盘工作目录*/
    "list_page_size":	    20,                               /*指定列出目录时分页大小*/
    "list_sort_name":	    "name",                           /*指定列出目录时排序字段*/
    "list_sort_direction":	"asc",                            /*指定列出目录时的排序方向*/
    "secure_method":	    "aes-cbc-128",                    /*指定上传时的加密方式*/
    "secure_key":	        "12345678",                       /*指定上传时的加密密钥,*/
                                                              /*下载时如检测到文件被加密,也使用此密钥解密*/
    "secure_enable":	    true,                              /*指定是否启用加密解密*/
                                                              /*如果设置为false,*/
                                                              /*下载时即使检查到文件加密,也不会解密*/
    "timeout_retry":	    true,                             /*当执行'synch'和'compare'命令时,
                                                                因为频繁调用api去获取目录下文件名称
                                                                将导致一些api调用超时,此选项用于控制超时时
                                                                是否重试。*/
    "max_thread":	        5,                                /*下载时允许的最大线程数*/
    "max_speed_per_thread": 0                                 /*设置的是单个线程的最大下载速度。0表示不限速。
                                                                单位为KiB。例,如果设置为100,共有5线程,
                                                                则总的最大下载速度将在500KiB/s上下浮动。*/
    "max_upload_speed_per_thread": 0,                         /*设置的是单个线程的最大上传速度。0表示不限速。
                                                                单位为KiB。例,如果设置为100,共有5线程,
                                                                则总的最大上传速度将在500KiB/s上下浮动。*/
    "user_agent": "netdisk;5.2.7;PC;PC-Windows;6.2.9200;WindowsBaiduYunGuanJia", /*指定 User-Agent。*/
	"cache_size": 1024	                                      /* 设置磁盘缓存大小 */
}

下载文件

baidupcs download [-f] <remote file> <local file>
baidupcs d [-f] <remote file> <local file>

只能下载文件,如果需要下载目录,请使用 'baidupcs synch -d <local dir> <remote dir>'。

选项:
  -f   如果本地文件存在的话,强制替换

示例:
  baidupcs download /backup/data.20140118.tar.gz ~/download/data.20140118.tar.gz

直接保存文本到网盘中

baidupcs echo [-a] <remote file> <text>

选项:
  -a  指定把文本添加到文件末尾,而不是完全替换
  
示例:
  baidupcs echo data.txt "The text that saved by baidupcs."

编码/解码本地文件

baidupcs encode [-def] <src> <dst>

选项:
  -d  使用上下文中的密钥来解密<src>文件并输出结果到<dst>中。
      程序会读取<src>文件并检测其加密方法。
  -e  使用上下文中的密钥和加密方法来加密<src>文件并输出结果到<dst>中。
  -f  强制覆盖<dst>文件。
  
示例:
  baidupcs encode -e data.txt data-sec.txt
  baidupcs encode -d data-sec.txt data-plain.txt
  baidupcs encode -h

修复文件(实验性功能)

baidupcs fix [-fh] <md5> <length> <scrap> <remote path>
  
  <md5>          指定文件的 MD5 值
  <length>       指定文件的字节大小
  <scrap>        下载的前 256KiB 的文件碎片
  <remote path>  修复成功后保存的网盘路径

修复文件。从国外网站下载文件时,如果速度比较慢,而你又知道文件的 MD5 值和文件大小,
那么你可以只下载前 256KiB 的内容,然后使用此命令来尝试修复文件。修复成功后,文件将
保存在 <remote path> 指定的网盘目录中,因此你将可以从百度网盘以较快的速度下载。
如果这个文件已经存在于百度网盘中的话(无论是否在自己的网盘中),修复的成功率应该是 100%。

示例:
   baidupcs fix -h
   baidupcs fix 39d768542cd2420771f28b9a3652412f 5849513984 ~/xxx.iso xxx.iso

查看帮助

baidupcs help [command name]

查看帮助。

示例:
   baidupcs help
   baidupcs help compare
   baidupcs help -h

列出网盘根目录下的文件或目录

baidupcs list [dir]
baidupcs ls [dir]

输出格式为:
    * 第一列指示是否是目录,如果是目录则输出 d,否则输出 -
    * 第二列是文件或目录的最后修改时间
    * 第三列是文件路径
    * 如果指定了 --thumb 选项,则第四列是缩略图地址(如果有的话)

示例:
   baidupcs list
   baidupcs list /music
   baidupcs list -h
   
列出目录时会自动分页显示,如果需要修改分页大小的话,
使用'baidupcs set --list_page_size=20'来修改,把list_page_size设置为0,则关闭分页。

登录网盘

baidupcs login [--username=<username>] [--password=<password>]

登录可能需要输入验证码。目前的处理办法是把验证码图片写入到本地文件,用户打开文件识别验证码。
可通过 'baidupcs set --captcha_file=<path> 来指定验证码保存路径,
例如:'baidupcs set --captcha_file=/var/www/xxx.com/captch.gif'将文件保存到网站目录下。
可通过 'baidupcs context' 查看当前的执行上下文。执行上下文包括验证码图片保存路径等其他信息。

示例:
  baidupcs login -h 可查看login命令的使用方法
  baidupcs login    会提示输入用户名和密码
  baidupcs login --username=gang 指定用户名登录
  baidupcs login --username=gang --password=123456 指定用户名和密码登录

退出网盘

baidupcs logout

显示网盘文件或目录的元数据

baidupcs meta <file>

示例:
   baidupcs meta
   baidupcs meta note.txt

创建目录

baidupcs mkdir <dir>

示例:
  baidupcs mkdir subdir
  baidupcs mkdir /music/china

移动网盘文件或目录

baidupcs move <src> <dst>
baidupcs mv <src> <dst>

示例:
  baidupcs move /data_20140118.txt /subdir/data.txt
  baidupcs move music /my/music

显示当前网盘的工作目录

baidupcs pwd

示例:
  baidupcs pwd

显示网盘配额

baidupcs quota [-e]

选项:
  -e   打印精确的网盘配额
  
示例:
   baidupcs quota
   baidupcs quota -e

删除文件或目录

baidupcs remove <path>
baidupcs rm <path>

示例:
  baidupcs remove /subdir/data_20140118.txt

重命名网盘文件或目录

baidupcs rename <src> <new name>
baidupcs ren <src> <new name>

注意:<new name>是新的文件名字,而不是文件路径。如果需要移动文件到另一个目录,请使用 'pcs move'。

示例:
  baidupcs rename /data.txt data_20140118.txt

设置上下文

baidupcs set [--captcha_file=<path>] [--cookie_file=<path>] ...

选项:
--captcha_file=<file path>         设置验证码图片保存路径
--cookie_file=<file path>          设置cookie文件路径
--list_page_size=<page size>       设置列出目录时分页大小
--list_sort_direction=[asc|desc]   设置列出目录时排序方向
--list_sort_name=[name|time|size]  设置列出目录时排序字段
--secure_enable=[true|false]       设置上传下载时是否启用加密
--secure_key=<key string>          设置加密解密密钥
--secure_method=[plaintext|aes-cbc-128|aes-cbc-192|aes-cbc-256] 设置加密方式
--timeout_retry=[true|false]       设置执行synch和compare时,获取目录下文件超时时,是否允许重试
--max_thread=<num>                 设置下载时允许的最大线程数
--max_speed_per_thread=<num>       设置单线程的最大下载速度。单位为KiB。详细查看'pcs context'命令中对上下文文件的说明
--max_upload_speed_per_thread=<num>设置单线程的最大上传速度。单位为KiB。详细查看'pcs context'命令中对上下文文件的说明
--user_agent=<user-agent>          设置 User-Agent。
--cache_size=<num>                 设置下载时磁盘缓存的大小。单位为 KiB。CTRL + C 中断下载时,磁盘缓存中的内容将丢失,需要再次下载。

示例:
  baidupcs set -h
  baidupcs set --cookie_file="/tmp/pcs.cookie"
  baidupcs set --captcha_file="/tmp/vc.git"
  baidupcs set --list_page_size=20 --list_sort_name=name --list_sort_direction=desc
  baidupcs set --secure_enable=true --secure_key=123456 --secure_method=aes-cbc-256

搜索文件

baidupcs search [-r] [dir] <key>

示例:
   baidupcs search note.txt          在当前工作目录搜索 note.txt
   baidupcs search /music desc.mp3   在/music目录搜索 desc.mp3
   baidupcs search -r note.txt       在当前工作目录递归搜索 note.txt
   baidupcs search -r /music desc.mp3 在/music目录递归搜索 desc.mp3

同步目录

baidupcs synch [-cdenru] <local path> <remote path>
baidupcs s [-cdenru] <local path> <remote path>

同步本地文件和远端文件、本地目录和远端目录。
默认选项是'-cdu',即上传需要上传的文件、下载需要下载的文件和打印无法确定上传下载的文件。

比较规则:(同'compare'一样)
  只通过时间来进行比较。
  I)  如果本地和远端都是文件:
        a) 本地最后修改时间大于网盘文件上传时间,则认为需要上传;
        b) 本地最后修改时间小于网盘文件上传时间,则认为需要下载;
           (此处注意:当一个文件上传到网盘后,其网盘时间肯定比本地最后修改时间大。
             如果此时执行比较的话,则会认为该文件需要从网盘下载。
             下载则没有此问题,因为一个文件下载后,程序会使用
             网盘时间来更新本地文件的最后修改时间。)
  II)  本地存在,网盘不存在,则认为需要上传
  III) 本地不存在,网盘存在,则认为需要下载
  IV)  如果一端是文件,另一端是目录,则认为无法确认是上传还是下载。

选项:
  -c  只打印出无法确定上传或下载的项。
      一般是因为本地是文件,远端是目录,或本地是目录远端是文件
  -d  只下载需要下载的文件或目录
  -e  只打印相同的文件或目录
  -n  只是打印,而不真正的执行上传和下载,等价于'compare'
  -r  递归比较其子目录
  -u  只上传需要上传的文件或目录

示例:
   baidupcs synch music music
   baidupcs synch -r ~/music music
   baidupcs synch -u music music     只上传需要上传的文件,等价于备份
   baidupcs synch -d music music     只下载需要下载的文件,等价于还原
   baidupcs synch -du music music    上传需要上传的文件,并且下载需要下载的文件,等价于同步
   
注意:推荐每次都带上'-c'选项,可以打印出不知道如何处理的文件或目录,防止漏上传或下载。

上传文件

baidupcs upload [-f] <local file> <remote file>
baidupcs u [-f] <local file> <remote file>

只能上传文件,如果需要上传目录,请使用 'pcs synch' 命令。

示例:
   baidupcs upload ~/data.tar.gz /backup/data.20140118.tar.gz

显示程序版本

baidupcs version

示例:
   baidupcs version

显示当前登录用户

baidupcs who

示例:
   baidupcs who

注意:

    1. 代码比较乱,以后空的时候重构。
    1. 启用加密后,分片上传逻辑未仔细测试。

问题:

    1. 上传大文件时,程序会计算文件的MD5值,此过程耗时较久。
    1. 下载大文件时,程序会在磁盘上预分配文件空间,此过程耗时较久。
    1. 上传大文件后,通过 'pcs meta'获取到的md5值与本地文件计算出的md5不匹配,这个应是百度网盘的bug。(测试时,把上传的文件下载到本地后,对比md5值是匹配的)

baidupcs's People

Contributors

bob-fu avatar boleynsu avatar elfsundae avatar gangzhuo avatar hipboi avatar hosiet avatar imzjy avatar luo87 avatar marks-yag avatar mayenjoy avatar moruoxian avatar pexcn avatar semigodking avatar tbfly avatar tenwx avatar vinewx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

baidupcs's Issues

cgi-bin

#OpenWRT

/www/cgi/pcs
文件内容:

!/bin/sh

echo "Content-type: text/html"
echo ""
set|while read LINE
do
echo $LINE"
"
done

pcs help

pcs(/usr/bin/pcs) help
任何参数都没有输出,用ssh(root)操作一切正常

set 输出的变量
CONTENT_LENGTH=''
CONTENT_TYPE=''
DOCUMENT_ROOT='/www'
GATEWAY_INTERFACE='CGI/1.1'
HOSTNAME='OpenWrt'
HTTP_ACCEPT='text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8'
HTTP_ACCEPT_CHARSET=''
HTTP_ACCEPT_ENCODING='gzip, deflate, '
HTTP_ACCEPT_LANGUAGE='en-US,en;q=0.8'
HTTP_AUTHORIZATION=''
HTTP_CONNECTION='keep-alive'
HTTP_COOKIE='PHPSESSID=8e2e41e7681e318af90f29b5b33b8674'
HTTP_HOST='192.168.1.1'
HTTP_REFERER=''
HTTP_USER_AGENT='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36'
HTTP_X_HTTP_METHOD_OVERRIDE=''
IFS='
'
OPTIND='1'
PATH='/sbin:/usr/sbin:/bin:/usr/bin'
PPID='2692'
PS1='w $ '
PS2='> '
PS4='+ '
PWD='/www'
QUERY_STRING=''
REDIRECT_STATUS='200'
REMOTE_ADDR='192.168.1.1'
REMOTE_HOST='192.168.1.1'
REMOTE_PORT='47433'
REQUEST_METHOD='GET'
REQUEST_URI='/cgi-bin/pcs'
SCRIPT_FILENAME='/www/cgi-bin/pcs'
SCRIPT_NAME='/cgi-bin/pcs'
SERVER_ADDR='192.168.1.1'
SERVER_NAME='192.168.1.1'
SERVER_PORT='80'
SERVER_PROTOCOL='HTTP/1.1'
SERVER_SOFTWARE='uhttpd'
SHLVL='1'

请问有解吗?

上传大文件后,md5文件不一致的可能解决方法

我看了下 bypy 的 解决方法,里面有提到这个问题, 希望可以作为参考
https://github.com/houtianze/bypy
简单说就是:大文件分片上传合并后,百度会返回错误的MD5值。这会导致文件比较失败(本地和远程同样的大文件被认为是不同的文件,因为拿到MD5不一样),进而导致syncup / syncdown重复上传下载。
曲线解决方法:syncup两次。(第二次大文件算是秒传,很快的;小文件不会再传。然后百度云端返回的MD5值都是正确的了)

百度云登录失败

Login Failed: Can't parse the response as object. Response: bd__cbs__pwxtn7({"errInfo":{ "no": "0" }, "data": { "rememberedUserName" : "", "codeString" : "", "token" : "219c1e732b1f961a2512f4f6c53d899c", "cookie" : "1", "usernametype":"", "spLogin" : "rate", "disable":"", "loginrecord":{ 'email':[ ], 'phone':[ ] } }}

下载操作未能识别参数类型为目录

pcs d /packages/index.html download/

以上指令会将index.html保存为本地文件download,而不是先创建本地目录download再将文件下载为download/index.html。是不是可以修改一下这个行为呢?毕竟mvcp这些工具都这么干的。

OpenWRT编译版无法安装

# ipkg install BaiduPCS_0.2.0_x86.ipk
Clearing state_want and state_flag for pkg=BaiduPCS (arch_priority=0 flag=16 want=2)
Nothing to be done
An error ocurred, return value: 4.
Collected errors:
Cannot find package BaiduPCS.
Check the spelling or perhaps run 'ipkg update'

不能上传目录

我觉得这个工具很好,下载没问题,可是目录上传不行.

pcs synch -u localdir /
Scanning local file system...
Completed
Fetching net disk file list...
Fetch 9
Completed
Comparing...

Completed

Download: off, Upload: on, Confuse: off, Equal: off
Printing|Synching...
Completed

Local File OP Net Disk File

Statistic:

Need Download: 9, Need Upload: 0
Confuse: 0, Equal: 0, Other: 0
Total: 9, Fail: 0

Notes:
<- means the right file will download into
the local file system.
-> means the left file will upload into the disk.
== means left file same as right file.

< means confuse, don't known how to.

还是我的用法有问题, 正常情况下,应该是可以的啊

建议上传文件的时候,增加命令行参数进行加密上传的功能.

感谢开发者的努力. 我一直在测试这个,感觉很好用. 但是我觉得有点需要改进下.就是在上传文件的时候, 可以通过命令行指定加密方式.
比如很多人有这种需求, 上传A文件的时候, 不加密上传. 上传B文件的时候, 又需要加密上传. 如果不能在命令行参数中控制, 每次上传完毕,都需要修改一次配置文件. 比较麻烦.
建议在上传文件的时候, 可以通过参数,手动指定是否加密上传

因为经常需要批量上传文件和文件夹. 每次都需要修改配置文件, 改来改去很麻烦

大文件上传,经常出现超时的错误.

前 99% 的速度, 上传的速度有异常的稳定, 如果中途有超时情况, 重试就可以过去. 但是每次到了99% 以后, 就很容易出现如下的错误提示. 然后就一直卡着不动.一直不停的重试.

Upload slice failed, retry delay 10 second, tid: 0x7f21b123d700. message: Timeout was reached: http://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&type=tmpfile&app_id=250528&BDUSS=***

如上, 如果上传超过12G或者更大的文件. 上传完成以后,就会出现这个错误. 而且重试了很多次,一直都提示同样的错误.

其实已经上传了99.99%.

重复出现如下错误.


Upload slice failed, retry delay 10 second, tid: 0x7f21b123d700. message: Timeout was reached: http://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&type=tmpfile&app_id=250528&BDUSS=***
Upload slice failed, retry delay 10 second, tid: 0x7f2166301700. message: Timeout was reached: http://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&type=tmpfile&app_id=250528&BDUSS=***
Upload slice failed, retry delay 10 second, tid: 0x7f21a0909700. message: Timeout was reached: http://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&type=tmpfile&app_id=250528&BDUSS=***
Upload slice failed, retry delay 10 second, tid: 0x7f21b123d700. message: Timeout was reached: http://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&type=tmpfile&app_id=250528&BDUSS=***
Upload slice failed, retry delay 10 second, tid: 0x7f2166301700. message: Timeout was reached: http://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&type=tmpfile&app_id=250528&BDUSS=***
Upload slice failed, retry delay 10 second, tid: 0x7f21a0909700. message: Timeout was reached: http://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&type=tmpfile&app_id=250528&BDUSS=***
Upload slice failed, retry delay 10 second, tid: 0x7f21b123d700. message: Timeout was reached: http://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&type=tmpfile&app_id=250528&BDUSS=***
Upload slice failed, retry delay 10 second, tid: 0x7f2166301700. message: Timeout was reached: http://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&type=tmpfile&app_id=250528&BDUSS=***
Upload slice failed, retry delay 10 second, tid: 0x7f21a0909700. message: Timeout was reached: http://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&type=tmpfile&app_id=250528&BDUSS=***
Upload slice failed, retry delay 10 second, tid: 0x7f21b123d700. message: Timeout was reached: http://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&type=tmpfile&app_id=250528&BDUSS=***


无法Login !

  1. cent os系统 和 Ubuntu 系统
  2. 输入验证码之后,没有反应。
  3. 怎么回事?

Unable to make on El Capitan

Wills-MacBook-Pro:BaiduPCS will$ brew info openssl
openssl: stable 1.0.2d (bottled)
OpenSSL SSL/TLS cryptography library
https://openssl.org/

This formula is keg-only.
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

/usr/local/Cellar/openssl/1.0.2d_1 (464 files, 18M)
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/openssl.rb
==> Dependencies
Build: makedepend ✔
==> Options
--universal
    Build a universal binary
--without-check
    Skip build-time tests (not recommended)
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

Wills-MacBook-Pro:BaiduPCS will$ make
makefile:23: "Use 'make ver=debug' to build for gdb debug."
mkdir -p bin/
cc -o bin/pcs.o -c -fPIC -D_FILE_OFFSET_BITS=64 pcs/pcs.c
pcs/pcs.c:10:11: fatal error: 'openssl/md5.h' file not found
# include <openssl/md5.h>
          ^
1 error generated.
make: *** [bin/pcs.o] Error 1

长的的文件名会提示错误

当下载的文件名是zh-hans_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74070.iso的时候会提示Error: The remote file not exist, or have error: The folder can not be moved, Error:2
但是当名字改成Windows_XP.iso就可以了。

怎么已经毫无反应了?

pcs who ,pcs login什么的,都是完全没输出了,这是怎么啦,
git pull亦提示是最新版本,大家的都怎么了?

文件上传限速

作者你好,请问有没有上传文件限制速度的选项,我看到了有下载的限速,但是没有找到。能不能支持一下上传限速(ubuntu版本)

登陆正确 但是提示失败

➜  playground pcs login
User Name: mask_mask
Password: 
Login Failed: Success
  • 登录失败
  • 其实用户名密码正确
  • 怀疑是百度passport的返回码改了 后面的Success应该是表示登陆成功, 但是代码改了

可否增加其它功能

可否增加以下功能:
1)离线下载,包括链接和BT
2)获取多媒体文件的DLNA地址,用于推送到电视盒子或其它设备播放

同步的不完美实现方式

新增一个功能:“同步上传”:本地文件上传网盘后,验证md5值,通过touch命令修改本地文件的时间与百度网盘中的一致。

在 VS 2013 编译 64bit 报错

error LNK1112: 模块计算机类型“X86”与目标计算机类型“x64”冲突 BaiduPCS-master\pcs\argp.lib(vsnprintf.obj) BaiduPCS_DLL

ls命令时自动转换文件的大小

pcs ls 输出格式是这样的
1044374762 2016-04-26 09:45:41 /video/marvel.75.years-from.pulp.to.pop.720p.hdtv.x264-bajskorv.mkv
文件大小(1044374762)是以 byte 为单位,阅读起来很不方便,希望能根据大小调整为 Kb,Mb等单位

Can't get the file size.

作者你好,我在同步文件到本地时,出现了【Can't get the file size.】错误。百度云上面对应的文件大小是0B,通过火狐浏览器是可以下载文件的。麻烦关注下

Error: Can't create the temp file (For large file only - i.e. > 2GB)

Version info

pcs version
pcs v0.2.1 (API v1.1.1)pcs

Listing for the size of /tv/jurassic.mkv (2.7GB)

pcs list /tv/
PAGE#1

D Size Modify Date Time File Name

d 0 2015-07-13 17:09:14 /tv/Jurassic.World.2015.1080p.HDRip.KORSUB.x264.AAC2.0-RARBG
d 0 2015-07-13 17:11:50 /tv/Jurassic.World.2015.720p.HC.HDRip.X264.AC3-EVO
d 0 2015-07-11 18:35:46 /tv/taxi

  • 2749372028 2015-07-13 17:16:40 /tv/jurassic.mkv

- 1807641558 2015-06-30 11:08:25 /tv/majong.mp4

Total: 4.24GB, File Count: 2, Directory Count: 3

Download /tv/jurassic.mkv and get the error

pcs download /tv/jurassic.mkv jurassic.mkv
Error: Can't create the temp file: jurassic.mkv.0deb2d970640a1bd8dedec8b92b7fd55.pcs_temp, maybe have no disk space.

Login Failed

你好!

今天下載了最新的 source code 去編譯。之後執行:
pcs login --username=myUsername --password=myPassword
就出現了:
Login Failed:

在百度盘可以看到是曾經有登入的:
15:12 香港香港 203.80.. Chrome 35.0 邮箱名登录 百度云
15:09 香港香港 203.80.. Chrome 35.0 邮箱名登录 百度云
15:07 香港香港 203.80.. Chrome 35.0 邮箱名登录 百度云

有其它地方要注意嗎?

上传文件的时候,一定要指定远程文件名

这个不一定是issue. 但是用起来不方便. 比如我要上传一个文件到远程的 / 目录下, 非要指定远程的文件名才行. 是否可以更新下, 如果远程为目录, 则默认用本地的文件名. 这样更方便一些.

python调用后出现错误

首先感谢作者,真的非常强大,我申请不大百度的PCS的接口权限,用这个非常方便。

下面是用的问题,我在树莓派上使用flask和python commends模块做了一个web gui,我的操作是:
1、首先安装成功了baidupcs,命令行下登录、列表、目录改名完成OK!命令行提示非常完美,新手友好;
2、我的flask下第一次使用 ret , data = commends.getstatusoutput("pcs list")
之后print data 列表完整,非常OK;
我ctrl c之后改成了 print ret \n return data问题就出现了。
3、现在不管是web还是cli,都出现:
pcs who
Wrong file size: Size=0, /home/pi/.pcs/pcs.context
Error: Can't read the context file (/home/pi/.pcs/pcs.context).
You are not logon or your session is time out. You can login by 'login' command.
————————————
事实上login命令也不行:
pcs login
Wrong file size: Size=0, /home/pi/.pcs/pcs.context
Error: Can't read the context file (/home/pi/.pcs/pcs.context).
——————————
提示pcs.context是空白文件;

我不知道是哪里卡住了,请求高手帮助。谢谢

为什么取得验证码的url,没有参数?

pcs -uUSER_NAME quota --urlc
COOKIE FILE: /root/.baidupcs/default.cookie
Password:
Login Failed: Can't get captch image from the server : https://passport.baidu.com/cgi-bin/genimage?

我发现报错以后, 简单改了一下代码,

url = pcs_utils_sprintf(URL_CAPTCHA "%s", code_string);
img = pcs_http_get_raw(pcs->http, url, PcsTrue, &imgsz); pcs_free(url);
if (!img) {
pcs_set_errmsg(handle, "Can't get captch image from the server : %s",url);
return PCS_NETWORK_ERROR;
}

想看看为什么会出错, 但是 url 是没有参数的, 请问如何修正, 谢谢

几个问题

1)树莓派raspbian下,用户pi登录网盘,并设置定时任务(crontab -e)来自动同步,但是pcs命令都执行失败。这个该如何解决?

2)pcs search查找不到结果,执行echo $?显示0。应该参考其它linux命令,查找不到结果时返回1。

3)pcs upload -f /local/a.txt /remote/a.txt 如果网盘不存在/remote/a.txt,会报错。应该改为程序自动判断网盘是否已存在该问题,若存在,则自动覆盖。既然已经加上-f,表示需要强制复制,为什么还要提示错误?

如果将文件加密上传,然后用普通的方式下载

如果将文件加密上传,然后用普通的方式下载,请问该用什么方式进行解密?
这个问题主要是考虑到这种情况. 我需要把爱情电影进行加密上传到百度云, 然后下载的时候,用百度云管家下载. 这个下载速度比较快. 因为上传是经过加密的.需要解密, 请问有没有相关的方法进行解密?

另外一个问题, 如果百度云网盘的网站接口发生了改变, 是不是需要重新编译源代码?

Can't read response codestring, but login successful anyways

Running ./pcs login displays an error, but afterwards running ./pcs who shows that I am logged in, and I can access my files with ./pcs ls. It seems that there was no captcha?

User Name: crossbowffs
Password: 
Login Failed: Can't read the codestring from the response. Response: <!DOCTYPE html><html><head><meta http-equiv=Content-Type content="text/html; charset=UTF-8"></head><body><script>


    var href = decodeURIComponent("http:\/\/pan.baidu.com\/res\/static\/thirdparty\/pass_v3_jump.html")+"?"

var accounts = '&accounts='

href += "err_no=18&callback=parent.bd__pcbs__msdlhs&codeString=&userName=crossbowffs&phoneNumber=&mail=&hao123Param=[...]&u=http://pan.baidu.com/&tpl=&secstate=&gotourl=&authtoken=&loginproxy=&resetpwd=&vcodetype=&lstr=&ltoken=&bckv=&bcsync=&bcchecksum=&code=&bdToken=&realnameswitch=0&bctime="+accounts;

if(window.location){
    window.location.replace(href);
}else{
   document.location.replace(href); 
}
</script>

无法使用手机号登录

用手机号码注册百度云帐号,使用手机号登录,验证码连续刷新3次后登录失败。
同一个帐号,添加用户名后,使用用户名登录可以成功。

Openwrt SDK无法编译

按步骤执行之后会
/home/ljkgpxs/src/openwrt/trunk/sdk/OpenWrt-SDK-ramips-mt7620_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/scripts/download.pl "/home/ljkgpxs/src/openwrt/trunk/sdk/OpenWrt-SDK-ramips-mt7620_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/dl" "0.2.0.tar.gz" "unknown" "https://github.com/GangZhuo/BaiduPCS/archive"
然后一直尝试下载0.2.0.tar.gz,直到失败。。。

Build failed on Mac OS X

It will fail when I build the project on Mac OS X(Mavericks, builtin gcc 5.0).
I fixed it by remove all of the inline functions, e.g., change

inline void append_mem_ent(struct pcs_mem *mem)

to

void append_mem_ent(struct pcs_mem *mem)

Do you have any idea on why this happen?
Thanks!

gcc -o bin/pcs bin/main.o bin/shell.o bin/pcs_io.o bin/shell_args.o bin/dir.o bin/hashtable.o bin/rc4.o bin/daemon.o bin/logger.o bin/sqlite3.o   -L./bin -lpcs -lm -lcurl -lssl -lcrypto
Undefined symbols for architecture x86_64:
  "_append_mem_ent", referenced from:
      _pcs_mem_malloc in libpcs.a(pcs_mem.o)
  "_argp_parse", referenced from:
      _shell_args_parse in shell_args.o
  "_chcmpi", referenced from:
      _pcs_utils_strcmpi in libpcs.a(pcs_utils.o)
  "_pcs_http_append_bytes", referenced from:
      _pcs_http_write in libpcs.a(pcs_http.o)
  "_pcs_http_parse_http_head", referenced from:
      _pcs_http_write in libpcs.a(pcs_http.o)
  "_pcs_http_perform", referenced from:
      _pcs_http_get in libpcs.a(pcs_http.o)
      _pcs_http_get_raw in libpcs.a(pcs_http.o)
      _pcs_http_post in libpcs.a(pcs_http.o)
      _pcs_http_get_download in libpcs.a(pcs_http.o)
      _pcs_post_httpform in libpcs.a(pcs_http.o)
  "_pcs_http_prepare", referenced from:
      _pcs_http_get in libpcs.a(pcs_http.o)
      _pcs_http_get_raw in libpcs.a(pcs_http.o)
      _pcs_http_post in libpcs.a(pcs_http.o)
      _pcs_http_get_download in libpcs.a(pcs_http.o)
      _pcs_post_httpform in libpcs.a(pcs_http.o)
  "_read_cookie_attr", referenced from:
      _pcs_http_get_cookie in libpcs.a(pcs_http.o)
  "_remove_mem_ent", referenced from:
      _pcs_mem_free in libpcs.a(pcs_mem.o)
  "_skip_cookie_attr", referenced from:
      _pcs_http_get_cookie in libpcs.a(pcs_http.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bin/pcs] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.