Rat's

GoIndex:一个无需服务器的Google Drive目录索引程序
说明:GoIndex是一款部署在Cloudflare Workers的Google Drive目录索引程序,无需提...
扫描右侧二维码阅读全文
16
2019/09

GoIndex:一个无需服务器的Google Drive目录索引程序

说明:GoIndex是一款部署在Cloudflare WorkersGoogle Drive目录索引程序,无需提供服务器,可以直接列出你谷歌网盘的所有文件,同时下载和访问也不需要挂梯子,也可以在线观看某些格式的视频文件,拿来玩玩也是可以的。

截图

请输入图片描述

安装

Github地址:https://github.com/donwa/goindex
备份地址:https://github.com/iiiiiii1/goindex

首先肯定是需要一个谷歌网盘的,个人的话容量有点小,如果想容量大的,可以免费申请一个无限容量的Google Drive网盘,申请方法查看→传送门

这里直接使用作者提供的快速部署方法,由于使用的是rclonegoogle api,高峰期难免会出现点问题,后面也会说下使用自己的api部署方法。

1、获取Workers代码
先访问:https://installen.gd.workers.dev/,点击GET AUTH CODE,验证你的谷歌账号获取Auth code

然后开始输入你的Auth code,其它可以先默认,然后点击BUILD获取你的代码。

开头的相关参数,可自行修改:

#站点名称
"siteName": "GoIndex",
#根目录访问密码,如不设置留空即可
"root_pass": "moerats",
#根目录ID,默认整个网盘文件夹,如果只想列出根目录某个文件夹,那么填入该文件夹ID即可。
"root": "root"

文件夹ID获取方法,点击根目录某个文件夹,地址栏为:https://drive.google.com/drive/folders/1C4Aro,则1C4Aro为文件夹ID

2、部署到Workers

首先登录cloudflare,官网→传送门,然后首页右侧可以看到Workers入口。
请输入图片描述

点进去后新建一个Workers子域名,也就是你的专属域名,填入确认后就更改不了了,所以别乱填。
请输入图片描述
接下来点击Create a Worker创建一个Worker
请输入图片描述
把你之前获取的Workers代码粘贴进去,然后可以在左上角双击修改域名,再点击Save and Deploy即可。
请输入图片描述
最后打开分配的子域名即可,此后修改配置可以自行修改Workers代码。

绑定域名

如果想绑定自己的域名,就需要先将自己的域名转到cloudflare,然后点自己的域名,解析一个A记录,IP地址随意。
请输入图片描述
然后在上方找到Workers,选择后,点击页面下的Add route,进行如下设置。
请输入图片描述
按照图中的格式,填上自己的域名,并选择对应的Workers程序即可。
请输入图片描述

API部署

这里也可以使用自己的API部署,好处就是安全点,高峰期也不容易爆炸,当然安装会麻烦点,如果不经常使用的话,还是建议用上面的方法快速部署。

1、获取GDrive客户端
先启用Google Drive API,启用地址:点击进入,注意这里使用个人账号操作。
请输入图片描述
再创建一个OAuth client ID,创建地址:点击进入。应用类型选择其他(Other),名称自己填,这里博主填的GoIndex
请输入图片描述
然后你会获得自己的客户端ID和客户端密钥,再复制下来。
请输入图片描述

2、获取refresh_token
这里使用Rclone来获取refresh_token,先登录VPS,先安装依赖,使用命令:

#CentOS系统
yum install p7zip unzip -y
#Debian/Ubuntu系统
apt install -y p7zip-full

再安装Rclone,使用命令:

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

开始配置,使用命令:

rclone config

会出现以下信息:

n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> Rats  #配置名称,随便填
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 / Dropbox
   \ "dropbox"
 9 / Encrypt/Decrypt a remote
   \ "crypt"
10 / FTP Connection
   \ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
12 / Google Drive
   \ "drive"
13 / Google Photos
   \ "google photos"
14 / Hubic
   \ "hubic"
15 / JottaCloud
   \ "jottacloud"
16 / Koofr
   \ "koofr"
17 / Local Disk
   \ "local"
18 / Mega
   \ "mega"
19 / Microsoft Azure Blob Storage
   \ "azureblob"
20 / Microsoft OneDrive
   \ "onedrive"
21 / OpenDrive
   \ "opendrive"
22 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
23 / Pcloud
   \ "pcloud"
24 / Put.io
   \ "putio"
25 / QingCloud Object Storage
   \ "qingstor"
26 / SSH/SFTP Connection
   \ "sftp"
27 / Union merges the contents of several remotes
   \ "union"
28 / Webdav
   \ "webdav"
29 / Yandex Disk
   \ "yandex"
30 / http Connection
   \ "http"
31 / premiumize.me
   \ "premiumizeme"
Storage> 12  #选择12,Google Drive,注意该序列号会随时变化,看清楚再填
client_id> 850428  #填上你的Google Drive客户端ID
client_secret> D72gPc  #填上你的Google Drive客户端密匙
Choose a number from below, or type in your own value
 1 / Full access all files, excluding Application Data Folder.
   \ "drive"
 2 / Read-only access to file metadata and file contents.
   \ "drive.readonly"
   / Access to files created by rclone only.
 3 | These are visible in the drive website.
   | File authorization is revoked when the user deauthorizes the app.
   \ "drive.file"
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ "drive.appfolder"
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ "drive.metadata.readonly"
scope> 1 
ID of the root folder
Leave blank normally.
Fill in to access "Computers" folders. (see docs).
Enter a string value. Press Enter for the default ("").
root_folder_id> 
Service Account Credentials JSON file path 
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file> 
Edit advanced config? (y/n)
y) Yes
n) No
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
n) No
y/n> n  #输入n
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/  #打开该地址获取code
Log in and authorize rclone for access
Enter verification code>hjdd   #输入你获取到的code
Configure this as a team drive?
y) Yes
n) No
y/n> n  #输入n
--------------------
[Rats]
type = drive
client_id = 85042871
client_secret = D72gPc
scope = drive
token = {"access_token":"y902Z"}  #记住里面的refresh_token参数
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y  #输入y
Current remotes:

Name                 Type
====                 ====
Rats                 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保存退出

此时我们在配置过程中就获取到了refresh_token参数,如果忘了的可以查看配置文件。

不知道配置文件在哪的,可以使用命令:

rclone config file | grep rclone.conf

3、获取并修改Workers代码
Workers代码可以点击该地址查看→传送门,先复制代码,部分修改可参考上面,不同的是,需要填上自己的api信息,如下:

#填上自己的api客户端,密匙和获取到的refresh_token
“client_id”:“20226481”,
“client_secret”:“X4Z3ca8”,
“refresh_token”:“”,

最后就可以部署Workers代码了,方法参考上面的快速部署。

Vultr新用户注册送100美元/16个机房按小时计费,支持支付宝,【点击查看】。
最后修改:2020 年 04 月 29 日 12 : 57 PM

发表评论 取消回复

125 条评论

  1. lqhww

    大佬现在用 的是哪家的vps?

    1. Rat's
      @lqhww

      一直是Spartanhost,https://www.moerats.com/archives/613/

  2. lqhww

    大佬现在用 的是哪家的vps?

  3. 你好

    突然发现,宝塔就是一个网盘程序啊。 要是能弄成在线播放。。。。

    1. Rat's
      @你好

      宝塔可以说是文件管理器吧

      1. 759177496
        @Rat's

        这个谷歌网盘怎么弄?

        1. Rat's
          @759177496

          无限容量的?文章有传送门

  4. zgm

    博主,handsome主题记得更新,加入了授权机制。

    1. Rat's
      @zgm

      好,感谢提醒,我都很久没关注更新了

  5. house.m.d.

    自定义api的话,那个refresh_token会过期吗?我自己申请的,貌似看到后面有个expiry里显示当天就过期了

    1. Rat's
      @house.m.d.

      会过期,不过可以用很久,具体多久不是很清楚。

      1. pq8o3q
        @Rat's

        博主,请问获得refresh_token后,在谷歌账号里去掉rclone的授权权限,这个refresh_token会失效吗

        1. Rat's
          @pq8o3q

          这个应该会,具体你试试

  6. jackma

    博主有点意思啊,加油啊。

  7. 心灵博客

    我只想问下能不能做图床和视频床?

    1. bbii
      @心灵博客

      可以用clevereto做床图

    2. Rat's
      @心灵博客

      请求大的话就不能,有请求数限制,超过就报错。

      1. house.m.d.
        @Rat's

        这个请求数的限制,是在cf还是在google drive,还是在google的api啊

        1. Rat's
          @house.m.d.

          主要是cf,gd的话,影响不大

      2. 小飞
        @Rat's

        有时间搞一下server应谁呗

        1. Rat's
          @小飞

          server应谁是啥

          1. 小飞
            @Rat's

            serveo ,说错了

  8. duang

    快速搭建好了,下载东西很慢,只有200k。可能是用的别人的api的缘故? 这个要是能支持团队盘就好了,教育网的网盘不好弄还不稳,团队盘倒是挺好弄的。

    1. kuku
      @duang

      支持团队盘的

    2. Rat's
      @duang

      下载速度貌似由CF决定,晚上cf好像都慢些,你试试IDM下载,团队盘还没用过。

      1. duang
        @Rat's

        https://github.com/maple3142/GDIndex
        看到有人修改了一下,改动在下面。
        GOIndex和GDIndex之间的区别
        前端基于Vue.js
        图像查看器不需要打开新页面
        视频播放器支持字幕(当前仅支持srt)
        在线PDF,EPUB阅读器
        没有目录级别的密码保护(.password)
        支持Http基本认证
        支持多个驱动器(个人,团队),而无需更改服务器代码

        1. ruin
          @duang

          那是Go好还是Gd好

  9. bush

    提示输入目录密码,是不是设置需要哪里注意一下

    1. Rat's
      @bush

      把root_pass参数留空,比如"root_pass": "",,这是根目录访问加密的参数