Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from iwestlin:master #7

Open
wants to merge 104 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
da20026
add single file support for tgbot
iwestlin Jul 11, 2020
c935289
changelog
iwestlin Jul 11, 2020
2f261a6
add docker version link
iwestlin Jul 11, 2020
a75f7aa
fix USE_PERSONAL_AUTH problem
SachiaLanlus Jul 11, 2020
6af2a36
Merge pull request #95 from SachiaLanlus/master
iwestlin Jul 11, 2020
5628f66
check USE_PERSONAL_AUTH while get file name
iwestlin Jul 11, 2020
4ec6e92
check files.length while copy files
iwestlin Jul 12, 2020
80f57e2
add command line option --limit for PARALLEL_LIMIT
iwestlin Jul 12, 2020
3ca3f89
consider more than 1 whitespaces in bot cmd
iwestlin Jul 12, 2020
8b8cce0
match file link like https://drive.google.com/file/d/1ZPjmP5GJ7bap_1R…
iwestlin Jul 12, 2020
f94e21e
extract folder link like folder/aaa/bbb/ccc as ccc...
iwestlin Jul 12, 2020
76f13ae
did not release memory?
iwestlin Jul 12, 2020
e6ebef9
add english version by roshanconnor123
iwestlin Jul 12, 2020
77e65d5
fix USE_PERSONAL_AUTH problem
Jul 13, 2020
5e77faf
Merge pull request #102 from SachiaLanlus/master
iwestlin Jul 13, 2020
56ad46b
tg bot count single file
iwestlin Jul 13, 2020
40d5bca
add update button and clear button for tg bot
iwestlin Jul 15, 2020
6cdf017
changelog
iwestlin Jul 15, 2020
1178f54
changelog
iwestlin Jul 15, 2020
7379704
check if is counting before update
iwestlin Jul 16, 2020
084fefc
add -y option to ./dedupe, add --sa option for service account files …
iwestlin Jul 16, 2020
515df81
changelog
iwestlin Jul 16, 2020
0df7829
readme
iwestlin Jul 16, 2020
b26879d
add --sfl option to show files length
iwestlin Jul 17, 2020
900e45b
ls_folder 遇到文件数特别的的目录时,可能还没获取完全文件,access_token就过期了
iwestlin Jul 17, 2020
6d9ff65
add bookmark export/import script
iwestlin Jul 17, 2020
faf7e7c
payload.timeout
iwestlin Jul 17, 2020
8f100a9
add readme toc
iwestlin Jul 18, 2020
5e33f98
toc
iwestlin Jul 18, 2020
27a49d7
readme
iwestlin Jul 18, 2020
44ccece
log error message when validating sa
iwestlin Jul 18, 2020
dcac4d7
handle_error for validate-sa
iwestlin Jul 18, 2020
7680ec0
validate-sa code 403
iwestlin Jul 18, 2020
a794bd8
FILE_EXCEED_MSG
iwestlin Jul 18, 2020
984798b
sm task id if task failed
iwestlin Jul 18, 2020
e0ce45b
release memory while copy_files throwing error?
iwestlin Jul 18, 2020
80b7172
readme
iwestlin Jul 19, 2020
f9b0d67
add --yes option for ./copy
iwestlin Jul 21, 2020
9caa4fe
try extract url from message body
iwestlin Jul 21, 2020
31fd1a8
send message if tg user not in whitelist
iwestlin Jul 21, 2020
000d15b
try extract url from message body
iwestlin Jul 21, 2020
1f6715d
try extract url from message body
iwestlin Jul 21, 2020
fb67757
add clear db script
iwestlin Jul 21, 2020
9a066c7
there might be \ in url
iwestlin Jul 21, 2020
b9aa2cf
changelog
iwestlin Jul 21, 2020
c2f0148
log error data when fail to send message to tg
iwestlin Jul 23, 2020
cfc4d48
only show recent 100 task records in case of message too long
iwestlin Jul 23, 2020
f0343b3
add arg endpoint for sm function
iwestlin Jul 25, 2020
e19339f
readme add @dissipator version
iwestlin Jul 26, 2020
72fa6ab
add aria2.js to help download folders
iwestlin Jul 27, 2020
a3b967a
changelog
iwestlin Jul 28, 2020
9f48867
add --dncf option for copy, meaning do not copy folders
iwestlin Aug 1, 2020
5e8ab73
如果sa连续两次遭遇userRateLimitExceeded才剔除之
iwestlin Aug 1, 2020
c2563b0
changelog
iwestlin Aug 1, 2020
a4edd21
changelog
iwestlin Aug 1, 2020
088a9a8
changelog
iwestlin Aug 2, 2020
ef47b1b
get_dir
iwestlin Aug 4, 2020
c05f21b
add --hashkey/--cf/--expire options for aria2.js
iwestlin Aug 4, 2020
f3bf12d
changelog
iwestlin Aug 4, 2020
021e71e
连续两次遇到消息包含rate limit的报错则剔除sa改为连续7次
iwestlin Aug 6, 2020
29dc943
将重置sa的时间间隔改为2小时
iwestlin Aug 6, 2020
fe4fe91
changelog
iwestlin Aug 6, 2020
f4e8b7a
如果复制文件时遇到的报错信息含有 rate limit,则不计入重试次数
iwestlin Aug 6, 2020
6ac7e7c
check gtoken
iwestlin Aug 6, 2020
0b33250
add https://github.com/roshanconnor123/Gdutils_Tgbot to readme
iwestlin Aug 7, 2020
90658a8
trim extracted url for messages like https://t.me/gdurl/9067
iwestlin Aug 8, 2020
db548d9
remove \\n in extracted url
iwestlin Aug 8, 2020
3bdc0da
add /reload for tgbot
iwestlin Aug 8, 2020
4c89fe8
add /reload for tgbot
iwestlin Aug 8, 2020
53300af
changelog
iwestlin Aug 8, 2020
3c46229
do not save summary to db if some folders counting not finished
iwestlin Aug 10, 2020
b942429
let function count makes use of record.summary if it can be
iwestlin Aug 10, 2020
193f6e3
db set summary to null if run count with update
iwestlin Aug 12, 2020
0722741
add export type snap2html for ./count
iwestlin Aug 13, 2020
255cd84
changelog
iwestlin Aug 13, 2020
74cdc13
escape * to * for snap2html
iwestlin Aug 15, 2020
72a6c29
handle rate limit error for personal account
iwestlin Aug 15, 2020
b815a7a
support copy single file for function copy
iwestlin Aug 21, 2020
ad4be88
USE_PERSONAL_AUTH -> service_account
iwestlin Aug 22, 2020
49443fe
record.summary might be null
iwestlin Aug 22, 2020
7c98e13
check smy before save to db
iwestlin Aug 22, 2020
aee6835
check smy before save to db
iwestlin Aug 22, 2020
c3572a6
handle error for get_info_by_id
iwestlin Aug 22, 2020
ded3ded
handle error inside of function get_info_by_id
iwestlin Aug 22, 2020
35bd257
throw error for gen_count_body
iwestlin Aug 22, 2020
e5b5ff4
return undefined for tg_copy if get_info_by_id failed
iwestlin Aug 22, 2020
37d20e1
format code
iwestlin Aug 22, 2020
3f61a64
check COPYING_FIDS for bot /copy command
iwestlin Aug 23, 2020
91c88c9
show top 20 rows if table too long for tg message
iwestlin Aug 28, 2020
61edfe6
keep folder row
iwestlin Aug 28, 2020
dc4e3b6
update count status every 10 seconds
iwestlin Aug 28, 2020
1b5394d
hide pending/processing_count if it is zero
iwestlin Aug 28, 2020
60a5158
edit prev message
iwestlin Aug 28, 2020
e38352a
changelog
iwestlin Aug 28, 2020
9defd5b
readme
iwestlin Sep 2, 2020
692c2af
fuck google
iwestlin Sep 12, 2020
bfdfba6
little fix
iwestlin Sep 20, 2020
c3c883e
handle_exit
iwestlin Oct 6, 2020
7f68266
把 rate limit 当成常规错误
iwestlin Oct 14, 2020
144b2ef
make google greate again
iwestlin Nov 23, 2020
a1ee766
little fix
iwestlin Nov 23, 2020
6c856ec
little fix
iwestlin Nov 23, 2020
f99a9c0
little fix
iwestlin Nov 23, 2020
86cf503
snap2html order by name
iwestlin Apr 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions aria2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env node

const fs = require('fs')
const crypto = require('crypto')

const { format_size } = require('./src/summary')
const { get_name_by_id, get_sa_token, get_access_token, walk_and_save, validate_fid } = require('./src/gd')

const ID_DIR_MAPPING = {}
const FOLDER_TYPE = 'application/vnd.google-apps.folder'

const { argv } = require('yargs')
.usage('用法: ./$0 <folder-id> [options]')
.alias('o', 'output')
.describe('output', '指定输出文件,不填默认为uri.txt')
.alias('u', 'update')
.describe('u', '不使用本地缓存,强制从线上获取源文件夹信息')
.alias('S', 'service_account')
.describe('S', '使用service account进行操作,前提是必须在 ./sa 目录下放置sa授权json文件')
.alias('k', 'hashkey')
.describe('k', '使用 https://github.com/iwestlin/gdshare 部署的网站所设置的hashkey,用于生成合法的下载链接')
.alias('c', 'cf')
.describe('cf', '使用 gdshare 部署的网站网址')
.alias('e', 'expire')
.describe('e', 'gdshare 直链过期时间,单位小时,默认值24')
.help('h')
.alias('h', 'help')

const [fid] = argv._
if (validate_fid(fid)) {
let { update, service_account, output, hashkey, cf, expire } = argv
output = output || 'uri.txt'
gen_input_file({ fid, update, service_account, output, hashkey, cf, expire })
.then(cmd => {
console.log('已生成', output)
console.log('执行命令即可下载:\n', cmd)
})
.catch(console.error)
} else {
console.warn('目录ID缺失或格式错误')
}

async function gen_input_file ({ fid, service_account, update, output, hashkey, cf, expire }) {
const root = await get_name_by_id(fid, service_account)
const data = await walk_and_save({ fid, service_account, update })
const files = data.filter(v => v.mimeType !== FOLDER_TYPE)
const folders = data.filter(v => v.mimeType === FOLDER_TYPE)
let result
if (hashkey && cf) {
result = [`# aria2c -c --enable-rpc=false -i ${output}`]
} else {
const access_token = service_account ? (await get_sa_token()).access_token : await get_access_token()
result = [`# aria2c -c --enable-rpc=false --header "Authorization: Bearer ${access_token}" -i ${output}`]
}
result = result.concat(files.map(file => {
const { id, name, parent, size } = file
const dir = get_dir(parent, folders)
const download_uri = (hashkey && cf) ? gen_direct_link({ file, hashkey, cf, expire }) : `https://www.googleapis.com/drive/v3/files/${id}?alt=media`
return `# 文件大小:${format_size(size)}
${download_uri}
dir=${root}${dir}
out=${name}`
}))
fs.writeFileSync(output, result.join('\n\n'))
return result[0].replace('# ', '')
}

function gen_direct_link ({ file, hashkey, cf, expire }) {
const { name, id } = file
const expired = Date.now() + (Number(expire) || 24) * 3600 * 1000
const str = `expired=${expired}&id=${id}`
const sig = hmac(str, hashkey)
if (!cf.startsWith('http')) cf = 'https://' + cf
return `${cf}/api/download/${name}?${str}&sig=${sig}`
}

function hmac (str, hashkey) {
return crypto.createHmac('sha256', hashkey).update(str).digest('hex')
}

function get_dir (id, folders) {
let result = ID_DIR_MAPPING[id]
if (result !== undefined) return result
result = ''
let temp = id
let folder = folders.filter(v => v.id === temp)[0]
while (folder) {
result = `/${folder.name}` + result
temp = folder.parent
if (ID_DIR_MAPPING[temp]) {
result = ID_DIR_MAPPING[temp] + result
return ID_DIR_MAPPING[id] = result
}
folder = folders.filter(v => v.id === temp)[0]
}
return ID_DIR_MAPPING[id] = result
}
28 changes: 28 additions & 0 deletions bookmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const fs = require('fs')
const {db} = require('./db')

const action = process.argv[2] || 'export'
const filepath = process.argv[3] || 'bookmarks.json'

if (action === 'export') {
const bookmarks = db.prepare('select * from bookmark').all()
fs.writeFileSync(filepath, JSON.stringify(bookmarks))
console.log('bookmarks exported', filepath)
} else if (action === 'import') {
let bookmarks = fs.readFileSync(filepath, 'utf8')
bookmarks = JSON.parse(bookmarks)
bookmarks.forEach(v => {
const {alias, target} = v
const exist = db.prepare('select alias from bookmark where alias=?').get(alias)
if (exist) {
db.prepare('update bookmark set target=? where alias=?').run(target, alias)
} else {
db.prepare('INSERT INTO bookmark (alias, target) VALUES (?, ?)').run(alias, target)
}
})
console.log('bookmarks imported', bookmarks)
} else {
console.log('[help info]')
console.log('export: node bookmark.js export bm.json')
console.log('import: node bookmark.js import bm.json')
}
59 changes: 58 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,67 @@
## 更新日志
> 更新方法:在 gd-utils 目录下,执行 `git pull` 拉取最新代码,如果你使用了 pm2 守护进程,执行`pm2 reload server`刷新生效。

### [2020-08-28]
- 如果统计表格长度超出telegram消息限制,只显示前20行记录(之前是显示概要)
- 当用机器人统计目录数比较多的链接时,10秒后返回进度详情,且之后每隔10秒更新一次进度信息。

### [2020-08-13]
- 给命令行 `./count` 添加 [snap2html](https://github.com/rlv-dan/Snap2HTML) 的导出方式,示例用法:
```bash
./count folderID -S -t snap -o example.html
```
导出html示例:[example.html](https://code.viegg.com/single/snap2html-example.html)
源文件夹链接:[999](https://drive.google.com/drive/folders/1A35MT6auEHASo3egpZ3VINMOwvA47cJG)

### [2020-08-08]
- 给机器人添加 `/reload` 指令,表示重启进程,中断所有进行中的任务(前提是进程由pm2守护)

### [2020-08-06]
- 由于最近`userRateLimitExceeded`的错误越来越频繁出现,看上去Google除了每日750G以外又加上了什么限制。我只好把剔除SA的条件从“连续2次”遇到这种报错消息改成了**连续7次**……这个值也可以自定义,只需要在`config.js`中导出一个 `EXCEED_LIMIT`的变量,具体方法请参考[专家设置](https://github.com/iwestlin/gd-utils/blob/master/readme.md#%E4%B8%93%E5%AE%B6%E8%AE%BE%E7%BD%AE)

- 另外为了用户体验还隐去了包含`rate limit`的报错信息,同时将重置SA(也就是重新启用被剔除的SA)改成了每2小时执行一次(原来是12小时)

### [2020-08-05]
- 配合[gdshare](https://github.com/iwestlin/gdshare)使用,给 [aria2.js](./aria2.js) 添加 `--hashkey` `--cf` `--expire` 选项,具体含义请执行 `./aria2.js -h` 查看。
使用示例:
```bash
./aria2.js folderID -k 'your hashkey' -c 'your.domain.com' -S
```
这条命令会在当前目录生成一个包含所有文件下载链接的文本文件并输出一条以 `aria2c` 开头的命令,执行这条命令即可调用[aria2c](https://aria2.github.io/)下载整个`folderID`目录,并保留目录结构。

### [2020-08-02] 关于“没有可用的SA”报错信息
- 最近Google Drive的 API 似乎有点抽风,转存新分享的资源时经常随机遇到`userRateLimitExceeded`(一般这种错误只会在SA用完每日转存流量750G时触发)的接口返回错误导致SA被剔除(即使是新加的SA也会遇到),而对于比较老的分享或者自己团队盘文件对拷则没问题。
不得已我只好修改了一下程序的逻辑,只有当SA连续两次遇到`userRateLimitExceeded`的错误时才会被剔除,在这种条件下,据我的观察,拷贝一个新分享的资源时,平均每转存100个文件会被剔除掉一个SA。
如果你不希望因为接口返回`userRateLimitExceeded`而剔除掉对应的SA,可以手动修改代码,方法见:https://github.com/iwestlin/gd-utils/issues/138#issuecomment-666156273
- 命令行添加 `--dncf` 参数,表示`do not copy folders`,即转存资源时不复制任何递归子目录,直接将所有文件拷贝到新生成的文件夹中。

[2020-07-28]
- 添加 [aria2.js](https://github.com/iwestlin/gd-utils/blob/master/aria2.js) 脚本,方便利用 `aria2c` 下载google drive目录,使用帮助可执行 `./aria2.js -h` 查看。

相关 issue: [https://github.com/iwestlin/gd-utils/issues/133](https://github.com/iwestlin/gd-utils/issues/133)
使用录屏:[https://drive.google.com/file/d/1lzN7R9Klw66C5UttUUDN3_EsN3pNs62q/view](https://drive.google.com/file/d/1lzN7R9Klw66C5UttUUDN3_EsN3pNs62q/view)

[2020-07-21]
- 添加数据库clear脚本,只需在`gd-utils`目录下执行`node clear-db.js`就可以删除所有获取的文件信息(但会保留拷贝记录和bookmark)同时减小数据库文件大小了
- 调整提取分享链接的方法,基本能够识别所有类型消息中的分享ID

[2020-07-17]
- 给命令行 `./dedupe` 添加 `--yes` (简写`-y`)选项,表示“若发现重复项,不询问直接删除”
- 给 `./copy` `./count` `./dedupe` 添加 `--sa` 选项,可指定sa目录位置
示例用法 `./count folderID -S --sa test`,表示读取 `./test` 目录下的sa json文件(而不是默认的./sa目录)

[2020-07-15]
- 给tg机器人添加「强制刷新」和「清除按钮」按钮。
点击「强制刷新」可以无视本地缓存强制从线上获取对应链接的文件信息,省去手动输入 `/count folderID -u` 的麻烦
点击「清除按钮」可以清除链接消息下的多个按钮,适合任务完成后清除,防止误触

[2020-07-11]
- 给tg机器人添加单文件链接(`https://drive.google.com/file/d/1gfR...`)转存功能

[2020-07-10]
- 添加树形导出类型,示例用法: `./count folder-id -S -t tree -o tree.html`

`tree.html`可直接用浏览器打开:
[tree.html](https://gdurl.viegg.com/api/gdrive/count?fid=1A35MT6auEHASo3egpZ3VINMOwvA47cJG&type=tree)可直接用浏览器打开:
![](./static/tree.png)

前端源码:[https://github.com/iwestlin/foldertree/blob/master/app.jsx](https://github.com/iwestlin/foldertree/blob/master/app.jsx)
Expand Down
8 changes: 8 additions & 0 deletions clear-db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { db } = require('./db')

const record = db.prepare('select count(*) as c from gd').get()
db.prepare('delete from gd').run()
console.log('已删除', record.c, '条数据')

db.exec('vacuum')
db.close()
2 changes: 2 additions & 0 deletions copy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const { argv } = require('yargs')
.usage('用法: ./$0 <source id> <target id> [options]\ntarget id可选,不填则使用config.js里的DEFAULT_TARGET')
.alias('u', 'update')
.describe('u', '不使用本地缓存,强制从线上获取源文件夹信息')
.alias('y', 'yes')
.describe('yes', '若发现拷贝记录,不询问直接继续上次的进度')
.alias('f', 'file')
.describe('f', '复制单个文件')
.alias('n', 'name')
Expand Down
2 changes: 1 addition & 1 deletion count
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { argv } = require('yargs')
.alias('s', 'sort')
.describe('s', '统计结果排序方法,可选值 name 或 size,不填则默认根据文件数量逆序排列')
.alias('t', 'type')
.describe('t', '统计结果输出类型,可选值 html/tree/json/all,all表示输出所有文件json数据,最好搭配 -o 使用。不填则默认输出命令行表格')
.describe('t', '统计结果输出类型,可选值 html/tree/snap/json/all,all表示输出所有文件json数据,最好搭配 -o 使用。不填则默认输出命令行表格')
.alias('o', 'output')
.describe('o', '统计结果输出文件,适合搭配 -t 使用')
.help('h')
Expand Down
14 changes: 14 additions & 0 deletions create-table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ CREATE TABLE "bookmark" (
CREATE UNIQUE INDEX "bookmark_alias" ON "bookmark" (
"alias"
);

CREATE TABLE "hash" (
"md5" TEXT NOT NULL,
"gid" TEXT NOT NULL UNIQUE,
"status" TEXT NOT NULL DEFAULT 'normal'
);

CREATE INDEX "hash_md5" ON "hash" (
"md5"
);

CREATE UNIQUE INDEX "hash_gid" ON "hash" (
"gid"
);
16 changes: 16 additions & 0 deletions db.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,20 @@ function create_table_bookmark () {
db.prepare(create_index).run()
}

create_table_hash()
function create_table_hash () {
const [exists] = db.prepare('PRAGMA table_info(hash)').all()
if (exists) return
const create_table = `CREATE TABLE "hash" (
"md5" TEXT NOT NULL,
"gid" TEXT NOT NULL UNIQUE,
"status" TEXT NOT NULL DEFAULT 'normal'
);`
db.prepare(create_table).run()
const create_index = 'CREATE INDEX "hash_md5" ON "hash" ("md5");'
db.prepare(create_index).run()
const create_index2 = 'CREATE INDEX "hash_gid" ON "hash" ("gid");'
db.prepare(create_index2).run()
}

module.exports = { db }
6 changes: 4 additions & 2 deletions dedupe
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const { argv } = require('yargs')
.usage('用法: ./$0 <folder-id> [options]')
.alias('y', 'yes')
.describe('yes', '若发现重复项,不询问直接删除')
.alias('u', 'update')
.describe('u', '不使用本地缓存,强制从线上获取源文件夹信息')
.alias('S', 'service_account')
Expand All @@ -13,8 +15,8 @@ const { dedupe, validate_fid } = require('./src/gd')

const [fid] = argv._
if (validate_fid(fid)) {
const { update, service_account } = argv
dedupe({ fid, update, service_account }).then(info => {
const { update, service_account, yes } = argv
dedupe({ fid, update, service_account, yes }).then(info => {
if (!info) return
const { file_count, folder_count } = info
console.log('任务完成,共删除文件数:', file_count, '目录数:', folder_count)
Expand Down
25 changes: 25 additions & 0 deletions md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env node

const { argv } = require('yargs')
.usage('用法: ./$0 <目录ID> [options]')
.example('./$0 1ULY8ISgWSOVc0UrzejykVgXfVL_I4r75', '获取 https://drive.google.com/drive/folders/1ULY8ISgWSOVc0UrzejykVgXfVL_I4r75 内的所有文件信息,并将各文件的md5值和ID存入本地数据库中')
.example('./$0 1ULY8ISgWSOVc0UrzejykVgXfVL_I4r75 -s 10mb', '获取指定目录的所有文件信息,将不小于10MB大小的文件的md5值和ID存入本地数据库中')
.alias('s', 'size')
.describe('s', '不填默认存储所有文件的md5记录,如果设置了这个值,则过滤掉小于这个size的文件,必须以b结尾,比如10mb')
.alias('u', 'update')
.describe('u', '强制从线上获取信息(无视是否存在本地缓存)')
.alias('N', 'not_teamdrive')
.describe('N', '如果不是团队盘链接,可以加上此参数以提高接口查询效率,降低延迟')
.alias('S', 'service_account')
.describe('S', '使用service account获取文件信息,前提是必须在./sa目录下放置SA json文件')
.help('h')
.alias('h', 'help')

const { save_md5, validate_fid } = require('./src/gd')
const [fid] = argv._
if (validate_fid(fid)) {
const { update, size, not_teamdrive, service_account } = argv
save_md5({fid, size, not_teamdrive, update, service_account}).catch(console.error)
} else {
console.warn('目录ID缺失或格式错误')
}
Loading