Metadata-Version: 2.4
Name: gdrive-zip
Version: 1.0.1
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/pypi/v/gdrive-zip?color=orange&logo=pypi&logoColor=white)](https://pypi.org/project/gdrive-zip/)

</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 — Save your credentials

Once you download your client secret JSON from Google Cloud:

**Option A (Recommended for pip users):**
Run this one command to auto-save it globally:
```bash
gdrive-zip --set-credentials ~/Downloads/credentials.json
```
*(This automatically copies it to `~/.gdrive-zip/credentials.json` on Linux/macOS or `C:\Users\<you>\.gdrive-zip\credentials.json` on Windows.)*

**Option B (Manual copy):**
Place `credentials.json` directly into your global config folder:
- **Windows:** `C:\Users\<username>\.gdrive-zip\credentials.json`
- **macOS / Linux:** `~/.gdrive-zip/credentials.json`

*(Run `gdrive-zip --config-dir` anytime to verify your configuration status!)*

**Option C (Per-project / Git clone):**
Place `credentials.json` in your current working directory or the cloned repo 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

# Pass a custom credentials file on the fly
gdrive-zip <FOLDER_URL> --credentials /path/to/credentials.json

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

# Check configuration directory & status
gdrive-zip --config-dir

# 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, authentication is cached in your global config (`~/.gdrive-zip/token.json`) — you won't be prompted again.

---

## Usage Reference

```
usage: gdrive-zip [-h] [--credentials PATH] [--set-credentials PATH]
                  [--config-dir] [--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
  --credentials PATH    Explicit path to credentials.json
  --set-credentials PATH
                        Copy credentials.json into ~/.gdrive-zip/ for global
                        use
  --config-dir          Show the ~/.gdrive-zip/ config directory path and
                        status
  --no-zip              Download files to a local directory instead of
                        creating a ZIP archive
  --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>
