PeterDing / BaiduPCS-Py

BaiduPCS API & App 百度网盘客户端 和 API
MIT License
678 stars 110 forks source link

无法使用 aria2 下载 #27

Open trump-7575 opened 3 years ago

trump-7575 commented 3 years ago

Describe the bug / 描述 bug 同一个文件,用 自带的 me 下载器是可以下载的,历时10分钟。但是使用 aria2 就出错了。

To Reproduce / 复现问题 Steps to reproduce the behavior:

  1. BaiduPCS-Py download Clash.for.Windows.Setup.0.9.5.exe -s 2 -d aria2 -o /dev/shm/baidu_download/

Screenshots / 问题截图 Download: /Clash.for.Windows.Setup.0.9.5.exe to /dev/shm/baidu_download/Clash.for.Windows.Setup.0.9.5.exe

03/17 18:50:09 [NOTICE] Downloading 1 item(s)

03/17 18:50:09 [ERROR] CUID#7 - Download aborted. URI=http: 。。。。

Exception: [AbstractCommand.cc:351] errorCode=22 URI=http:。。。。 -> [HttpSkipResponseCommand.cc:239] errorCode=22 The response status is not successful. status=403

03/17 18:50:09 [NOTICE] Download GID#02c69835d4f0b49e not complete: /dev/shm/baidu_download/Clash.for.Windows.Setup.0.9.5.exe.tmp

Download Results: gid |stat|avg speed |path/URI ======+====+===========+======================================================= 02c698|ERR | 0B/s|/dev/shm/baidu_download/Clash.for.Windows.Setup.0.9.5.exe.tmp

Status Legend: (ERR):error occurred.

aria2 will resume download if the transfer is restarted. If there are any errors, then see the log file. See '-l' option in help/man page for details. aria2c fails. return code: 22

Envrionment / 运行环境

* 请按照下面的步骤贴出运行日志 ~/.baidupcs-py/running.log 中的内容。

  1. ~/.baidupcs-py/running.log 文件为空。
PeterDing commented 3 years ago

我猜测应该是 aria2 获取 Content-Length 时出现的错误。 起初我猜测应该是 BaiduPCS-Py 设置的 aria2 参数有问题,但是等我尝试下面几种参数时也报相同的错误 -> [HttpSkipResponseCommand.cc:240] errorCode=22 The response status is not successful. status=403

  1. '-x' '2' '-s' '2' '-k' '1048576'
  2. '-x' '2' '-s' '2' '-k' '1048576' --enable-http-pipelining="true" -j1024 --allow-piece-length-change="true" --piece-length="1M"

所以,我猜测 aria2 在获取 Content-Length 时,应该没有加 range header。应为 me, aget_py, aget_rs 下载器在获取 Content-Length 时,都是加 range header 的。它们都能正常工作。

因为百度服务器默认如果请求的文件内容大于 100MB(猜测) 则返回 403。所以当你在用 aria2 下载大于 100MB 的文件时总是报 403 错误。

因此,如果你下载大于 100MB 的文件时,请用 me, aget_pyaget_rs 下载器。

PeterDing commented 3 years ago

对 aria2 抓包显示,aria2 的第一次请求确实没有 range header.

Screen Shot 2021-03-18 at 10 08 41 AM