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

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

截图

请输入图片描述
GoIndex

GoIndex安装

Github地址:https://github.com/donwa/goindex (已被清除)
备份地址:https://github.com/iiiiiii1/goindex

最新可用https://github.com/alx-xlx/goindex

最新教程 直达

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

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

1、获取Workers代码
先访问:https://installen.gd.workers.dev/,或者 https://gdindex-code-builder.maple3142.net/ 点击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代码了,方法参考上面的快速部署。

最新教程

goindex
goindex-license
GitHub Release Date
GitHub last commit
goindex-softwareheritage.org
GitHub repo size

Google Drive Directory Index
Combining the power of Cloudflare Workers and Google Drive will allow you to index you files on the browser on Cloudflare Workers.

index.js is the content of the Workers script.

Versions

1. Aicirou/goindex-theme-acrou

Worker Script (Dark Mode) : index.js

Worker Script (Multiple Google Accounts) : index-multiple-accounts.js

Demo – goindex.teamsdrives.workers.dev

Copy the index.js script to workers.dev and edit client_idclient_secretrefresh_token with yours

OR

GoIndex Auto Code Builder

https://goindex.glitch.me/

Simply visit this Modified (only for Dark Mode) version to automatically generate your index.js without having to manually edit anything.

List View – Dark Mode

goindex-list

Thumbnail View – Dark Mode

goindex-thumbnail
goindex-awesome

Toggle View

goindex-toggle-view

2. maple3142/GDIndex


Worker Script – index.js

Upload Files using CLI gdindex_upload.py

## Python Example
import requests

# "upload: true" in the script
to_upload = "https://i.imgur.com/8w2KDrG.gif"
baseURL = "https://gdindex-dark.teamsdrives.workers.dev/"
# "folder1/folder2/goindex.gif"
# Subdirectories of Folder in Google Drive
fileName = "folder1/folder2/goindex.gif"
# Default teamDriveID is "root"
teamDriveID = "0ANCHcQq-8cmvUk9PVA"

URL = baseURL + "/" + fileName + "?rootId=" + teamDriveID + "&url=" + to_upload
r = requests.put(URL)
print(r.text)

Demo – gdindex-dark.teamsdrives.workers.dev

Demo – Dark Mode

3. donwa/goindex

Workers Script – index.js

Themes

Demo Classic : goindex-classic.teamsdrives.workers.dev

Demo Material: goindex-material.teamsdrives.workers.dev

Deployment

1.Install rclone software locally
2.Follow https://rclone.org/drive/ bind a drive
3.Execute the commandrclone config file to find the file rclone.conf path
4.Open rclone.conf,find the configuration root_folder_id and refresh_token
5.Download index.js in https://github.com/donwa/goindex and fill in root and refresh_token
6.Deploy the code to Cloudflare Workers

Free Teamdrives

Get free Google Shared Drives

Quick Deployment

1.Open https://goindex.glitch.me/
2.Auth and get the code
3.Deploy the code to Cloudflare Workers

Optional

Use this when you want to host everything

Get Google ClientID and SecretID

Log into the Google API Console [https://console.developers.google.com/] with your Google account. It doesn’t matter which Google account you use. (It need not be the same account as the Google Drive you want to access)

Select a project or create a new project.

Under “ENABLE APIS AND SERVICES” search for “Drive”, and enable the “Google Drive API”.

Click “Credentials” in the left-side panel (not “Create credentials”, which opens the wizard).

It will prompt you to set the OAuth consent screen product name, if you haven’t set one already.

OAuth Consent Screen > User Type > External > Application Name

Click “Credentials” in the left-side panel, then “Create credentials”, then “OAuth client ID”.

Choose an application type of “other”, and click “Create”. (the default name is fine)

It will show you a client ID and client secret. Use these values in rclone config to add a new remote or edit an existing remote

Setup rclone

Install rclone software locally
Follow https://rclone.org/drive/ bind a drive

Use the client_id & client_secret while setup

Execute the command rclone config file to find the file rclone.conf path

open rclone’s config file, here we will find following Configurations (we will need these in next steps)

  • client_id
  • client_secret
  • refresh_token
  • ROOT_FOLDER (will be like 0AG1OSyxjvYcLUk9PVA)

Setup Cloudfare Workers

Go to [https://workers.cloudflare.com/]

signup using email and password enter a subdomain [____.workers.dev] —> Set up

Choose Workers Plan (FREE)

  • FREE – 10000 request/day
  • $5/month – 10M requests/month

Verify Email Goto Workers —> “Create a Worker”

Now copy the Content of the index.js to the script section

Edit this object in the script with the details you generated above

var authConfig = {
    "siteName": "GoIndex", // Sitename
    "root_pass": "",  // root password, leave it blank if you don't want
    "version" : "1.0.6", // Program Version
    "hash" : "master", // master OR your HASH, do not leave blank (changes each time you make a commit)
    "theme" : "classic", // material  classic 
    "client_id": "****************************.apps.googleusercontent.com", // client_id from rclone config
    "client_secret": "*******************", // client_secret from rclone config
    "refresh_token": "******************************************", // authorized refresh token from rclone config
    "root": "0AG1OSyxjvYcLUk9PVA" // ROOT_FOLDER from rclone config,
};

Important Note :

  • if you have binded Teamdrive with rclone then make sure you specify the TeamDrive’s root folder. Example – [“root”: “0AG1OSyxjvYcLUk9PVA”]
  • but if you want to use “My Drive” then simply write “root”. Example – [“root”: “root”]
  • Each time you make a commit to a file its HASH changes, so to access the new file you have to specify the hash OR keep it default "hash" : "master"

Host src file in your own github repo

why ?

you can change the icon of the folders and files and much more

replace the below line in head with yours

<USERNAME>
<REPOSITORY>
<VERSION or HASH>
</PATH/TO/FILE>
src="//cdn.jsdelivr.net/combine/gh/jquery/jquery/dist/jquery.min.js,gh/<USERNAME>/<REPOSITORY>@<VERSION or HASH>/PATH/TO/FILE.js"

Example :

src="//cdn.jsdelivr.net/combine/gh/jquery/jquery/dist/jquery.min.js,gh/alx-xlx/[email protected]${authConfig.hash}/themes/${authConfig.theme}/app.js"

Change Icons

SOON https://www.w3.org/Icons/ https://www.w3.org/icons/ https://www.base64-image.de/

About

Cloudflare Workers allow you to write JavaScript which runs on all of Cloudflare’s 150+ global data centers.

Credits – Original Authors

goindex-theme-acrou – Aicirou

GDIndex – maple3142

goindex – donwa