Rclone 挂载 Google Drive实现个人离线播放系统

系统centos7,
无限空间谷歌云,
实现方法,由vps上的transmission下载到本地后,自动上传到谷歌云。tr有缓存文件夹和默认目录,在完成后会自动复制到默认目录,将谷歌云挂载到默认目录即刻实现下载后上传到谷歌云。

1.安装Rclone

1
2
3
4
5
wget https://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-current-linux-amd64.zip
chmod 0777 ./rclone-*/rclone
cp ./rclone-*/rclone /usr/bin/
rm -rf ./rclone-*

2.配置

rclone config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
[root@instance-5 ~]# rclone config
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n  #新建配置
name> ct  #随便填,后面要用到
Type of storage to configure.
Choose a number from below, or type in your own value
 1 / Amazon Drive
   \ "amazon cloud drive"
 2 / Amazon S3 (also Dreamhost, Ceph, Minio)
   \ "s3"
 3 / Backblaze B2
   \ "b2"
 4 / Box
   \ "box"
 5 / Cache a remote
   \ "cache"
 6 / Dropbox
   \ "dropbox"
 7 / Encrypt/Decrypt a remote
   \ "crypt"
 8 / FTP Connection
   \ "ftp"
 9 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
10 / Google Drive
   \ "drive"
11 / Hubic
   \ "hubic"
12 / Local Disk
   \ "local"
13 / Microsoft Azure Blob Storage
   \ "azureblob"
14 / Microsoft OneDrive
   \ "onedrive"
15 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
16 / Pcloud
   \ "pcloud"
17 / QingCloud Object Storage
   \ "qingstor"
18 / SSH/SFTP Connection
   \ "sftp"
19 / Webdav
   \ "webdav"
20 / Yandex Disk
   \ "yandex"
21 / http Connection
   \ "http"
Storage> 10  #选择10,Google Drive
Google Application Client Id - leave blank normally.
client_id>  #留空 
Google Application Client Secret - leave blank normally.
client_secret>  #留空
Service Account Credentials JSON file path - needed only if you want use SA instead of interactive login.
service_account_file> 
Remote config
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine or Y didn't work
y) Yes
n) No
y/n> n  #选择n
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth....  #复制到浏览器打开,获取验证码
Log in and authorize rclone for access
Enter verification code>  #填入上面获取到的验证码
Configure this as a team drive?
y) Yes
n) No
y/n> y  #选择y
Fetching team drive list...
No team drives found in your account--------------------
[ct]
client_id = 
client_secret = 
service_account_file = 
token = {"access_token":"ya29.GltFBd7UJN2qrxdG8FnG_rMjdL7glvXtfV"}
team_drive = 
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y  #选择y
Current remotes:
 
Name                 Type
====                 ====
ct                 drive
 
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退出

3.完成后挂载为磁盘
此处因为

1
2
3
4
5
rclone mount ct: /home/transmission/Downloads --allow-other --allow-non-empty --vfs-cache-mode writes &
#格式为[name]:[google drive dir] [mount dir]
#[name]就是配置文件是输入的name,例如我的就是ct
#[google drive dir] 这个是谷歌云盘的目录,根目录的花直接空开就可以了
#[mount dir]就是本地挂载位置,/home/transmission/Downloads

挂载完成后看看效果

1
2
3
4
5
6
7
8
9
10
11
[root@instance-5 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        1.8G     0  1.8G   0% /dev
tmpfs           1.9G     0  1.9G   0% /dev/shm
tmpfs           1.9G  8.4M  1.8G   1% /run
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1        10G  7.5G  2.6G  75% /
ct:             1.0P     0  1.0P   0% /home/transmission/Downloads
tmpfs           370M     0  370M   0% /run/user/1000
/dev/sdb        500G  374G  126G  75% /home/transmission/tmp
tmpfs           370M     0  370M   0% /run/user/0

出现的这1.0P的就是挂载上去的无限空间谷歌云
到此基本上已经实现了离线播放

4.设置开机自动挂载谷歌云

1
2
3
4
5
wget http://ctnmb.com/dl/rcloned && vim rcloned
#然后修改文件内如下内容
NAME=""  #[name]
REMOTE=''  #[google drive dir]
LOCAL=''  #[mount dir]

4.1设置自启动

1
2
3
4
mv rcloned /etc/init.d/rcloned
chmod +x /etc/init.d/rcloned
vim /etc/rc.d/rc.local #在末尾加入bash /etc/init.d/rcloned start
chmod +x /etc/rc.d/rc.local

然后就可以每次开机自启动了

由于我一开始只开了个10g的小鸡鸡,所以连做缓存的压力也很大,所以我也挂载多了一个500g的分区上去
所以参考其他文章
gcp(centos7)挂载额外磁盘
transmission+flexget自动下载删除文件刷pt

添加评论

  1. ym回复 2018-12-12 15:20

    看到博主的几篇文章,实在太有用了。
    正想着用gcp主机挂下载外加远程点播来着。

    • nmsl to ym 2019-07-07 12:33
      回复

      背景太tm瞎眼了

  2. paiban回复 2018-12-23 23:25

    需要评论一下,证明不是敌人