Aria2+Rclone+OneDrive打造自己专属的离线网盘

本教程实现了 下载文件到服务器,下载完成后上传到OneDrive,上传完成后自动删除留在服务器硬盘上的离线文件,代码看不清的请点击最下方的阅读原文

前排提醒!!!本文中代码部分 # 符号后面都为注释说明,这将会成为某些代码的操作说明。

一、准备工作

想要完美搭好这套设备 你需要以下条件:

聪明的大脑

使用搜索引擎的能力

较好的语文功底

眼睛不瞎

自我解决问题的能力

提问问题前经过大脑思考

非常充足的时间(顺利的话1小时左右能搭建完成)

一台服务器(推荐配置:1CPU+4G内存+20G以上的硬盘+1Gbps带宽+无限流量),服务器主机可以在这个网站捡漏 便宜VPS

一台本地计算机(win10系统最好,本教程是基于win10编写)

本地ssh软件,例如Xshell

会百度一些简单的 linux 命令的使用方法

必要时需要有个本地连接外网的工具?

二、安装宝塔面板(非必要)

(1) 根据自己服务器主机型号复制对应的安装命令,官网教程;本人机子是CentOs7系统,所以输入

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh

(2) 安装完成后,根据提示信息打开宝塔面板,

(3) 然后点击首页,在弹出的框框中,选择只安装 Nginx

(4)点击 安全 放行6800端口

三、安装Aria2

(1) 这里使用 Aria2 一键安装管理脚本 增强版(打不开用这个备用地址)执行下面的代码下载并运行脚本,出现脚本操作菜单输入 1 开始安装。

wget -N https://raw.githubusercontent.com/P3TERX/aria2.sh/master/aria2.sh && chmod +x aria2.sh && ./aria2.sh

备用的脚本:

wget -N https://raw.githubusercontent.com/ifwlzs/aria2.sh/master/aria2.sh && chmod +x aria2.sh && ./aria2.sh

(2) 安装成功后,再次输入上述安装代码,这次输入数字 12,自动更新BT-Tracker。

(3) 执行成功后,再次输入上述安装代码,这次输入数字 8,记录下 ipv4地址 和 RPC密钥 后续操作需要用到。

四、安装Rclone

(1)服务器端安装:输入下面的命令进行安装

curl https://rclone.org/install.sh | sudo bash

(2)本地(win10)安装rclone,下载链接:https://rclone.org/downloads/

(3)在本地 Win­dows 电脑上下载后,然后解压出来,解压后进入文件夹,在资源管理器地址栏输入 cmd,回车就会在当前路径打开命令提示符。输入以下命令:

rclone authorize “onedrive”

接下来会弹出浏览器,要求你登录账号进行授权。授权完后命令提示符窗口会出现以下信息:

If your browser doesn’t open automatically go to the following link: http://127.0.0.1:53682/auth

Log in and authorize rclone for access

Waiting for code…

Got code

Paste the following into your remote machine —>

{“access_token”:”xxxxxxxx”} # 注意!复制{xxxxxxxx}整个内容,并保存好,后面需要用到

<—End paste

(4) linux上配置 Rclone

TIPS: 因为 RCLONE 会时不时进行更新,当你看到这篇教程时菜单选项可能已经发生了略微的改动,但大致思路不会变,不要无脑照搬操作。

服务器里输入

rclone config

会出现以下信息,参照下面的注释进行操作。

n) New remote

s) Set configuration password

q) Quit config

n/s/q> n # 选择n,新建

name> OneDrive # 输入名称,类似于标签,用于区分不同的网盘。

Type of storage to configure.

Enter a string value. Press Enter for the default (“”).

Choose a number from below, or type in your own value

1 / 1Fichier

\ “fichier”

2 / Alias for an existing remote

\ “alias”

3 / Amazon Drive

\ “amazon cloud drive”

4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)

\ “s3”

5 / Backblaze B2

\ “b2”

6 / Box

\ “box”

7 / Cache a remote

\ “cache”

8 / Citrix Sharefile

\ “sharefile”

9 / Dropbox

\ “dropbox”

10 / Encrypt/Decrypt a remote

\ “crypt”

11 / FTP Connection

\ “ftp”

12 / Google Cloud Storage (this is not Google Drive)

\ “google cloud storage”

13 / Google Drive

\ “drive”

14 / Google Photos

\ “google photos”

15 / Hubic

\ “hubic”

16 / In memory object storage system.

\ “memory”

17 / Jottacloud

\ “jottacloud”

18 / Koofr

\ “koofr”

19 / Local Disk

\ “local”

20 / Mail.ru Cloud

\ “mailru”

21 / Mega

\ “mega”

22 / Microsoft Azure Blob Storage

\ “azureblob”

23 / Microsoft OneDrive

\ “onedrive”

24 / OpenDrive

\ “opendrive”

25 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)

\ “swift”

26 / Pcloud

\ “pcloud”

27 / Put.io

\ “putio”

28 / QingCloud Object Storage

\ “qingstor”

29 / SSH/SFTP Connection

\ “sftp”

30 / Sugarsync

\ “sugarsync”

31 / Tardigrade Decentralized Cloud Storage

\ “tardigrade”

32 / Transparently chunk/split large files

\ “chunker”

33 / Union merges the contents of several upstream fs

\ “union”

34 / Webdav

\ “webdav”

35 / Yandex Disk

\ “yandex”

36 / http Connection

\ “http”

37 / premiumize.me

\ “premiumizeme”

38 / seafile

\ “seafile”

Storage> 23 # 选择23,Microsoft OneDrive

** See help for onedrive backend at: https://rclone.org/onedrive/ **

 

Microsoft App Client Id

Leave blank normally.

Enter a string value. Press Enter for the default (“”).

client_id> # 留空,回车

Microsoft App Client Secret

Leave blank normally.

Enter a string value. Press Enter for the default (“”).

client_secret> # 留空,回车

Edit advanced config? (y/n)

y) Yes

n) No (default)

y/n> n # 选n

Remote config

Use auto config?

* Say Y if not sure

* Say N if you are working on a remote or headless machine

y) Yes (default)

n) No

y/n> n # 选n

For this to work, you will need rclone available on a machine that has

a web browser available.

 

For more help and alternate methods see: https://rclone.org/remote_setup/

 

Execute the following on the machine with the web browser (same rclone

version recommended):

 

rclone authorize “onedrive”

 

Then paste the result below:

result> {“XXXXXXXX”} # 上面保存的token复制到这里

Choose a number from below, or type in an existing value

1 / OneDrive Personal or Business

\ “onedrive”

2 / Root Sharepoint site

\ “sharepoint”

3 / Type in driveID

\ “driveid”

4 / Type in SiteID

\ “siteid”

5 / Search a Sharepoint site

\ “search”

Your choice> 1 # 这里问你要选择的类型,选1

Found 1 drives, please select the one you want to use:

0: OneDrive (business) id=xxxxxxxxx

Chose drive to use:> 0 # 程序找到网盘,这里编号是0,就选择0

Found drive ‘root’ of type ‘business’, URL: https://sbfc6-xxxxxxx.sharepoint.com/personal/xxxxxxxxxx/Documents

Is that okay?

y) Yes (default)

n) No

y/n> y # 选y

——————–

[OneDrive]

type = onedrive

token = {“xxxxxxxxx”}

drive_id = xxxxx

drive_type = business

——————–

y) Yes this is OK (default)

e) Edit this remote

d) Delete this remote

y/e/d> y # 选y

Current remotes:

 

Name Type

==== ====

OneDrive onedrive

 

e) Edit existing remote

n) New remote

d) Delete remote

r) Rename remote

c) Copy remote

s) Set configuration password

q) Quit config

e/n/d/r/c/s/q> q # 选q,退出

至此,Rclone 已成功连接到了 OneDrive 网盘。

五、配置服务器端Aria2文件

(1)nano的基础知识:

搜索某段文字:Ctrl+w 然后输入搜索的文字

保存并退出:Ctrl+x 之后输入 y 然后 回车

(2)服务器上输入

nano /root/.aria2c/script.conf

打开附加功能脚本配置文件进行修改,有中文注释,按照自己的实际情况进行修改,一般只需要修改网盘名称。

修改效果如下:

# 网盘名称(RCLONE 配置时填写的 name)

drive-name=OneDrive

(3)再次输入如下代码:

nano /root/.aria2c/aria2.conf

打开 Aria2 配置文件进行修改。找到“下载完成后执行的命令”,把 clean.sh替换为 upload.sh。

# 下载完成后执行的命令

on-download-complete=/root/.aria2c/upload.sh

(4)重启 Aria2

service aria2 restart

六、本地安装Aria2 前端面板 AriaNg

网上的教程太多了,这里我们用最实用的方案,你只需在win上准备以下条件:

本地机子能上网

有一个基于 Chromium 内核的浏览器(例如Chrome,新版edge)

能上外网(或者你可以找镜像下载插件网站也行,这里推荐个网址 CrxDown )

(针对不能打开谷歌商店的朋友)百度离线安装crx插件的能力

(1)安装 * Aria2forchrome *谷歌商店链接:https://chrome.google.com/webstore/detail/aria2-for-chrome/mpkodccbngfoacfalldjimigbofkhgjn

插件特征ID: mpkodccbngfoacfalldjimigbofkhgjn

七、配置AriaNg,开启离线时代

(1)打开插件,点击AriaNg设置,选择添加新的配置

(2)然后注意!!根据之前生成Aria2的配置,填好下图中 框住 部分

(3)点击 重新加载 后点 激活

(4)测试是否链接成功 失败会显示下图

成功后会显示如下

至此,我们的离线下载系统算是彻底搭建完成了,可以自己试试效果~

八、本教程参考及引用出处

Aria2 + Rclone 实现 OneDrive、Google Drive 等网盘离线下载

Aria2 + Rclone 实现离线下载,可配置自动上传至OneDrive

About the Author

发表评论

邮箱地址不会被公开。 必填项已用*标注

You may also like these