首先需要创建 Google 服务账号,并生成 JSON 格式的密钥。将该密钥文件保存到“~/.gdrive”目录中。

安装 go 语言。

yum install golang

将 go 配置到 PATH 环境变量中。在“~/.bashrc”加“export PATH=~/go/bin:$PATH”。

安装 gdrive。

go get github.com/prasmussen/gdrive

尝试下载目录。

# gdrive download --service-account Google服务账户密钥.json --recursive 1NAs78a38xkl1MhodoD7BM0Lh3v_sFwYs
Failed to get file: googleapi: Error 403: Project 1001876711724 is not found and cannot be used for API calls. If it is recently created, enable Drive API by visiting https://console.developers.google.com/apis/api/drive.googleapis.com/overview?project=1001812345678 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., accessNotConfigured

“1ZyNAJCd18wZVqpDkysGBF1WxgmYwFeqy”是目录的ID,例如:“https://drive.google.com/drive/folders/1NAs78a38xkl1MhodoD7BM0Lh3v_sFwYs?usp=sharing”。

根据提示,在浏览器中打开提示中的地址,启动 Google Drive API。

再下载。

# gdrive download --service-account Google服务账户密钥.json --recursive 1NAs78a38xkl1MhodoD7BM0Lh3v_sFwYs
Downloading data.mdb -> recognition_test_sets/ic15_1811/data.mdb
Downloading lock.mdb -> recognition_test_sets/ic15_1811/lock.mdb
Downloading data.mdb -> recognition_test_sets/ic03_867/data.mdb
Downloading lock.mdb -> recognition_test_sets/ic03_867/lock.mdb
Downloading data.mdb -> recognition_test_sets/svt_647/data.mdb
Downloading lock.mdb -> recognition_test_sets/svt_647/lock.mdb
Downloading data.mdb -> recognition_test_sets/ic15_2077/data.mdb
Downloading lock.mdb -> recognition_test_sets/ic15_2077/lock.mdb
Downloading data.mdb -> recognition_test_sets/IIIT5K_3000/data.mdb
Downloading lock.mdb -> recognition_test_sets/IIIT5K_3000/lock.mdb
Downloading data.mdb -> recognition_test_sets/ic13_1015/data.mdb
Downloading lock.mdb -> recognition_test_sets/ic13_1015/lock.mdb
Downloading data.mdb -> recognition_test_sets/cute80_288/data.mdb
Downloading lock.mdb -> recognition_test_sets/cute80_288/lock.mdb
Downloading data.mdb -> recognition_test_sets/svt_p_645/data.mdb
Downloading lock.mdb -> recognition_test_sets/svt_p_645/lock.mdb

  1. How to download a folder from google drive using terminal?
  2. https://github.com/prasmussen/gdrive
  3. https://github.com/odeke-em/drive

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注