Offline-downloading is very well-known word in China. It’s a service to allow you to set downloading tasks and a server will prepare the downloaded file for you to fetch at a high speed.
However, the problem is that I don’t like the client itself. It’s full of ads, and I don’t even want to use it. Some net disk service does not allow you to use a third-party client to download, so you cannot use general offline downloading method to download a large file in a net disk. As well, it’s a kind of monopoly. Just take Baidu Netdisk as an example, its downwards bandwidth is limited to 256KBps. If you want to download a large file, you have to keep your computer on and use their client to download your file. It’s immoral, but they provide free service.
Today, I will make offline downloading available for files in Baidu Netdisk. The tool I’m using is BaiduPCS and Linux screen.
Make BaiduPCS run on non-root access Linux system
As the document on GitHub, it requires some packages like openSSL. But the accademy VPS doesn’t allow me to install the package using system package manager.
At first, I thought I could make a static compile from another Linux computer. But I changed my mind because that meant I had to maintain the makefile which is not an easy job.
As a result, I decided to find a way to use a user library path, which I found is by setting LD_LIBRARY_PATH env var. More details are here.
At the beginning, I make the project on my Linux, and I copied the executable to uni’s accademy VPS via SCP. I ran it, but it shows cannot find xxxx version number. So used such command to copy it from an existing device.
cd /
find | grep libcrypto.so.1.0.0
And then I got the full path, SCP again and again until the dependency problem fixed.
All my runtime libraries are stored in ~/libs so I have to specify the library path and the environment variable.
Because the Linux is using CShell, I have to edit .cshrc and add one line:
setenv LD_LIBRARY_PATH /....../libs
source ~/.cshrc
Then the application should be able to work. In my case, I copied all the libraries files from a certain directory from the compiling system and it worked.
Start offline downloading
To offline downloading, we need to start a screen method. Generally, I like to run:
screen -R baidu/xxxx xxxxx
Then just follow the user namual, you should know how to download a file.
A quite reference for extarcting iso files
You know, some times you need to extract iso files without su permissions. :P
xorriso -osirrox on -indev image.iso -extract / extracted_iso_image
“离线下载”在国内是个家喻户晓的词。它指的是一种让你提交下载任务后,由服务器先帮你把文件下好、再供你高速取回的服务。
不过问题在于,我实在不喜欢这类下载客户端本身。里面全是广告,我连碰都不想碰。而且有些网盘服务不允许使用第三方客户端下载,所以常规的离线下载方式根本下不了网盘里的大文件。说白了,这也是一种垄断行为。拿百度网盘举个例子,它的下行带宽被限速到了 256KBps。你要是想下个大文件,就只能一直开着电脑挂着官方客户端慢慢拖。挺不厚道的,但谁让人家提供免费服务呢。
今天,我就来给百度网盘里的文件安排上离线下载。用到的工具是 BaiduPCS 和 Linux screen。
让 BaiduPCS 在无 root 权限的 Linux 系统上运行
按照 GitHub 上的文档说明,它依赖 openSSL 等几个软件包。但学校的学术 VPS 不允许我用系统包管理器安装软件。
一开始,我想着可以在另一台 Linux 电脑上做静态编译。但后来我改主意了,因为那样我就得自己折腾维护 makefile,可不是件轻松活。
最后,我决定想办法指定用户级的库搜索路径,查了下可以通过设置 LD_LIBRARY_PATH 环境变量来实现。更多细节可以参考这里。
起初,我在自己的 Linux 上编译好项目,然后通过 SCP 把可执行文件传到了学校的学术 VPS 上。一运行,提示找不到某某版本号的动态库。于是我就用下面这条命令从现有机器上把它找出来:
cd /
find | grep libcrypto.so.1.0.0
拿到完整路径后,再用 SCP 传过去——如此反复,直到所有依赖问题全部解决。
我把所有运行时依赖库都放在了 ~/libs 目录下,所以需要指定库路径并配置好环境变量。
因为这台 Linux 用的是 CShell,所以我需要编辑 .cshrc 并加上下面这一行:
setenv LD_LIBRARY_PATH /....../libs
source ~/.cshrc
这样程序应该就能正常运行了。就我的情况而言,我把编译机某个目录下的所有库文件都拷了过来,结果一次跑通。
开始离线下载
要进行离线下载,我们需要先启动一个 screen 会话。通常我习惯这样运行:
screen -R baidu/xxxx xxxxx
接下来照着用户手册操作,你就知道怎么下载文件啦。
附:解压 ISO 文件速查
你懂的,有时候你得在没有 su 权限的情况下解压 ISO 文件。:P
xorriso -osirrox on -indev image.iso -extract / extracted_iso_image