GoIndex - 一个无需服务器的Google Drive目录索引方案

简介:GoIndex是一款部署在Cloudflare Workers的Google Drive目录索引小程序。无需服务器,可以直接列出谷歌网盘的所有文件并且可以直接下载其中的文件。

功能:

  • 部署在 CloudFlare Workers的小程序。
  • 可以将 Google Drive 文件以目录形式列出,并直连下载。
  • 流量走 CloudFlare ,网速由 CloudFlare 决定。

部署方案1:使用自己的API部署。安全,高峰期也不容易炸。
1、使用个人账号登录Google Drive并启用Google Drive API。传送门
goindex-1.png
2、配置同意屏幕(如果以前没有配置过API)
goindex-2.png
3、创建一个 OAuth client ID(传送门),名称自己填。
goindex-3.png
4、保存好你的客户端ID和密钥
goindex-4.png
5、下载rclone(传送门),以获取refresh_token参数。注意:获取Google Drive返回的token需要全局姿势,建议使用sstap。(这里以windows版的rclone为例)
6、解压,CDM 进入解压目录,运行“rclone config”。(如需查看配置文件位置,执行“rclone config file”即可)

D:\rclone>rclone config  #配置
2019/09/28 13:40:25 NOTICE: Config file "C:\\Users\\ttydy\\.config\\rclone\\rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n  #新建远程
name> gd  #名称随意
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  #选择Google Drive
** See help for drive backend at: https://rclone.org/drive/ **

Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a string value. Press Enter for the default ("").
client_id> 371010059610-obu091on8hd4a272p0rtsdglrgu1gqek.apps.googleusercontent.com  #客户端ID
Google Application Client Secret
Setting your own is recommended.
Enter a string value. Press Enter for the default ("").
client_secret> aaaxPiQk2tWfDDF0SwsWdR  #客户端密钥
Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default ("").
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  #选择No
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> y  #选择Yes
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
Configure this as a team drive?
y) Yes
n) No
y/n> n  #选择No
--------------------
[gd]
type = drive
client_id = 111110059610-obu091on8hd4a272p0rtsdglrgu1gqek.apps.googleusercontent.com
client_secret = aaaacxPiQk2tWfDDF0SwsWdR
scope = drive
token = {"access_token":"ya29.Il-RB9LgOdjRYsgoxNzwDNHvDpqtkVuSmJNWfar3snSg3TI8UzjjLc0kxmTgPTcIUNnwzTNVh0eR4AY3zQVIB9C0yPRxiA32Yc3D_n4dJLZWGfwZOVc6im5Av22DNaaaaa","token_type":"Bearer","refresh_token":"1/R5PCB5h1eMGhEq6uYYPy79aaaaa3ZIv0JGYO52Wu0AU","expiry":"2019-09-28T14:41:18.8994441+08:00"}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y  #选择Yes this is OK
Current remotes:

Name                 Type
====                 ====
gd                   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  #保存并退出

7、获取根目录ID,url中folders后即为目录。
goindex-8.png

8、登录cloudflare,传送门。选择右侧的Workers
goindex-5.png

9、新建一个Workers子域名。注:填入确认后就更改不了了,注意不要乱填。
goindex-6.png

10、点击Create a Worker新建一个Worker
goindex-7.png

11、清空里面的内容,获取并修改GoIndex代码,传送门。将下面红色部分修改为你自己的。
goindex-9.png

12、完成后修改左上角的域名,再点击Save and Deploy即可。
goindex-10.png

部署方案2:使用rclone官方注册的API密钥。
(作者不会记录refresh_token,但为避免纠纷,建议有条件的同学使用方案1进行部署)

1、访问https://install.gd.workers.dev/
2、授权认证后,生成部署代码。
3、复制代码 到 CloudFlare 部署。

最后修改:2019 年 09 月 29 日 08 : 14 PM

发表评论