This repository is a Rust port of the upstream Python project:
It provides:
- A
gdownCLI that mirrors the upstream CLI surface as closely as practical. - A
gdownlibrary crate for embedding in other Rust projects.
The main goal is the same as upstream: download files (and folders) from Google Drive links that are shared as "Anyone with the link".
-
Google Drive files
- Accepts file IDs (e.g.
1abc...) and a variety of Google Drive URL shapes. - Handles Google Drive confirmation pages (virus-scan / quota / large file warnings).
- Supports Google Docs/Sheets/Slides export via
--format.
- Accepts file IDs (e.g.
-
Google Drive folders
- Accepts folder IDs and folder URLs.
- Recursively downloads the folder tree.
- Matches upstream’s “max 50 entries” behavior unless
--remaining-okis passed.
-
Streaming by default
- File bodies are streamed to disk (or stdout) using a fixed-size buffer.
- Confirmation HTML pages are read with a hard limit (
512KiB) to avoid accidental RAM blowups.
If you maintain a tap/formula, install it like:
brew install gdownIf you don’t have a brew formula yet, you can install via Cargo.
cargo install --locked --path .gdown FILE_ID
gdown "https://drive.google.com/uc?id=FILE_ID"
gdown "https://drive.google.com/file/d/FILE_ID/view?usp=sharing" --fuzzygdown FILE_ID -O output.bin
gdown FILE_ID -O ./downloads/gdown FILE_ID -O - > output.bingdown FILE_ID -O output.bin --continuegdown FOLDER_ID --folder -O ./out/
gdown "https://drive.google.com/drive/folders/FOLDER_ID?usp=sharing" --folder -O ./out/gdown DOC_ID --format pdf
gdown SHEET_ID --format xlsx
gdown SLIDES_ID --format pdfgdown FILE_ID --proxy http://proxy:8080
gdown FILE_ID --no-check-certificate
gdown FILE_ID --speed 10MBAdd to Cargo.toml:
[dependencies]
gdown = { path = "." }use gdown::{download, DownloadOptions};
fn main() -> Result<(), gdown::Error> {
let opts = DownloadOptions {
url: Some("https://drive.google.com/uc?id=FILE_ID".to_string()),
output: Some("output.bin".to_string()),
quiet: true,
..DownloadOptions::default()
};
let _path = download(&opts)?;
Ok(())
}use gdown::{download_folder, DownloadFolderOptions};
fn main() -> Result<(), gdown::Error> {
let opts = DownloadFolderOptions {
url: Some("https://drive.google.com/drive/folders/FOLDER_ID".to_string()),
output: Some("./out/".to_string()),
..DownloadFolderOptions::default()
};
let _result = download_folder(&opts)?;
Ok(())
}cargo test
cargo clippy --all-targets- This port aims to match upstream behavior closely, but it is not a byte-for-byte reimplementation.
- Folder listings follow upstream’s pragmatic limitation (50 items per folder page) unless overridden with
--remaining-ok.
MIT