Metadata-Version: 2.4
Name: gdrive-zip
Version: 1.0.0
Summary: Download a Google Drive folder as a single ZIP file — no 2 GB split limit.
Author-email: Sanja <your@email.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/SanjayKumar301/gdrive-zip
Project-URL: Bug Tracker, https://github.com/SanjayKumar301/gdrive-zip/issues
Project-URL: Repository, https://github.com/SanjayKumar301/gdrive-zip
Keywords: google-drive,download,zip,cli,gdrive,drive
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Environment :: Console
Classifier: Topic :: Utilities
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: google-auth>=2.0
Requires-Dist: google-auth-oauthlib>=1.0
Requires-Dist: google-api-python-client>=2.0
Requires-Dist: tqdm>=4.0
Dynamic: license-file

<div align="center">

# 📦 gdrive-zip

**Download an entire Google Drive folder as a single ZIP file.**

No more 2 GB split archives. No browser needed after setup.

[![Python](https://img.shields.io/badge/python-3.8%2B-blue?logo=python&logoColor=white)](https://python.org)
[![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
[![PyPI](https://img.shields.io/badge/pip-gdrive--zip-orange?logo=pypi&logoColor=white)](https://pypi.org)

</div>

---

## Why?

When you click **"Download"** on a Google Drive folder, Drive splits large folders into multiple **~2 GB ZIP files**. You then have to download each one, extract them separately, and reassemble — tedious and error-prone.

`gdrive-zip` talks directly to the **Drive API**, downloads every file itself, and writes a **single ZIP archive** (zip64-enabled, no size cap). One command. One file.

---

## Features

| Feature | Details |
|---|---|
| ✅ Single ZIP output | No 2 GB split — zip64 handles folders of any size |
| ✅ Recursive folders | Preserves the full nested folder structure inside the ZIP |
| ✅ Google Docs export | Docs → `.docx`, Sheets → `.xlsx`, Slides → `.pptx`, Drawings → `.png` |
| ✅ Shared folders | Works for "anyone with the link" and "Shared with me" |
| ✅ Progress bars | Real-time per-file download progress via `tqdm` |
| ✅ `--no-zip` mode | Extract directly to a local folder instead |
| ✅ Cached auth | Logs in once; stores a local token for future runs |

---

## Quick Start

### 1. Install

```bash
pip install gdrive-zip
```

> **Or run directly from source:**
> ```bash
> git clone https://github.com/SanjayKumar301/gdrive-zip.git
> cd gdrive-zip
> pip install -e .
> ```

---

### 2. One-Time Setup (~5 minutes)

`gdrive-zip` uses the Google Drive API, which requires a free OAuth2 credential from your Google Cloud account. You only do this once.

<details>
<summary><strong>▶ Click to expand setup instructions</strong></summary>

#### Step 1 — Create a Google Cloud project

1. Go to [console.cloud.google.com](https://console.cloud.google.com/)
2. Click **"New Project"** → give it any name (e.g. `gdrive-zip`) → **Create**

#### Step 2 — Enable the Drive API

1. In the top search bar, type **"Google Drive API"** → click it
2. Click **"Enable"**

#### Step 3 — Configure the OAuth consent screen

1. Go to **APIs & Services → OAuth consent screen**
2. Choose **"External"** user type → **Create**
3. Fill in:
   - **App name**: `gdrive-zip` (or anything)
   - **User support email**: your Gmail address
   - **Developer contact email**: your Gmail address
4. Click **Save and Continue** through all steps (you can leave optional fields blank)
5. On the **"Test users"** page, click **"+ Add users"** and add your own Gmail address

#### Step 4 — Create OAuth credentials

1. Go to **APIs & Services → Credentials → + Create Credentials → OAuth client ID**
2. Application type: **"Desktop app"**
3. Name: anything (e.g. `gdrive-zip-client`)
4. Click **"Create"**

#### Step 5 — Download and place the credentials file

1. In the credential list, find the one you just created
2. Click the **download icon** (↓) on the right
3. Rename the downloaded file to **`credentials.json`**
4. Place it in the **same directory as the script** (or the installed package folder)

</details>

---

### 3. Run

```bash
# Download a shared folder (paste the URL directly)
gdrive-zip https://drive.google.com/drive/folders/1AbCDeFGhIJkLmNoPQRsTuVwXyZ

# Specify a custom output filename
gdrive-zip https://drive.google.com/drive/folders/1AbCDe... my_archive.zip

# Use a raw folder ID instead of a URL
gdrive-zip 1AbCDeFGhIJkLmNoPQRsTuVwXyZ

# Download to a directory instead of a ZIP
gdrive-zip https://drive.google.com/drive/folders/1AbCDe... --no-zip

# Check the version
gdrive-zip --version
```

The **first time** you run it, a browser window will open asking you to sign in to Google and approve read-only Drive access. After that, a `token.json` is cached locally — you won't be prompted again.

---

## Usage Reference

```
usage: gdrive-zip [-h] [--no-zip] [--version] FOLDER [OUTPUT]

positional arguments:
  FOLDER      Google Drive folder URL or bare folder ID
  OUTPUT      Output filename (default: drive_download.zip)
              or output directory when --no-zip is used (default: drive_download)

options:
  -h, --help  show this help message and exit
  --no-zip    Download files to a local directory instead of creating a ZIP
  --version   show program's version number and exit
```

---

## How It Works

```
gdrive-zip <folder_url>
    │
    ├─ OAuth2 login (browser, one-time only)
    │
    ├─ Drive API: recursively list all files & subfolders
    │
    ├─ For each file:
    │     ├─ Regular files  → get_media()
    │     └─ Google Docs/Sheets/Slides → export_media() → .docx/.xlsx/.pptx
    │
    └─ Write everything into a single ZIP (zip64, no size cap)
```

---

## File Structure (after cloning)

```
gdrive-zip/
├── drive_folder_downloader.py   # Main script / entry point
├── credentials.example.json     # Template — copy to credentials.json
├── requirements.txt
├── pyproject.toml
├── LICENSE
└── README.md
```

> **Note:** `credentials.json` and `token.json` are excluded from git via `.gitignore`. They are never committed.

---

## Supported Google-Native Types

| Google Type | Exported As |
|---|---|
| Google Docs | `.docx` (Word) |
| Google Sheets | `.xlsx` (Excel) |
| Google Slides | `.pptx` (PowerPoint) |
| Google Drawings | `.png` |
| Forms, Sites, etc. | ⚠️ Skipped (no export format) |

---

## Requirements

- Python 3.8+
- A free Google Cloud project with the Drive API enabled
- `credentials.json` (see [One-Time Setup](#2-one-time-setup-5-minutes))

Dependencies (installed automatically via pip):

```
google-auth
google-auth-oauthlib
google-api-python-client
tqdm
```

---

## Troubleshooting

| Problem | Fix |
|---|---|
| `credentials.json not found` | Complete the [One-Time Setup](#2-one-time-setup-5-minutes) and place the file next to the script |
| `403 Access Denied` | Make sure you added your Gmail to the "Test users" list in the OAuth consent screen |
| `404 File not found` | The folder ID in the URL may be wrong, or the folder isn't shared with your account |
| Browser doesn't open | Run on a machine with a browser; or set up a service account for headless use |
| Google Docs skipped | Export limit exceeded (very large Docs files); retry or open and re-save in Drive |

---

## Contributing

Pull requests are welcome! Please:

1. Fork the repo
2. Create a feature branch: `git checkout -b feature/my-feature`
3. Commit your changes: `git commit -m "Add my feature"`
4. Push and open a PR

For major changes, open an issue first to discuss what you'd like to change.

---

## License

MIT — see [LICENSE](LICENSE).

---

<div align="center">

Made with ☕ · [Report a bug](https://github.com/SanjayKumar301/gdrive-zip/issues)

</div>
