Skip to main content

A fast, lightweight Python package for downloading any file from Google Drive

Project description

gdlcli - Google Drive Loader

PyPI version Python versions License: MIT

A fast, lightweight Python package for downloading any file from Google Drive. Simple CLI tool and powerful Python library.

๐Ÿš€ Features

  • โšก Fast & Reliable: Optimized downloads with progress tracking and resume capability
  • ๐ŸŽฏ Universal: Download any file type from Google Drive (docs, sheets, videos, images, etc.)
  • ๐Ÿ”— Smart URL Parsing: Supports all Google Drive URL formats automatically
  • ๐Ÿ“ฆ Multiple Interfaces: Use as CLI tool or import as Python library
  • ๐Ÿ›ก๏ธ Robust: Built-in retry logic, error handling, and fallback mechanisms
  • โš™๏ธ Configurable: Flexible configuration system with sensible defaults
  • ๐Ÿ–ฅ๏ธ Cross-Platform: Works on Windows, macOS, and Linux

๐Ÿ“‹ Table of Contents

๐Ÿ”ง Installation

From PyPI (Recommended)

pip install gdlcli

From GitHub

pip install git+https://github.com/mfaeezshabbir/gdlcli.git

Development Installation

git clone https://github.com/mfaeezshabbir/gdlcli.git
cd gdlcli
pip install -e .

Requirements

  • Python 3.6+
  • requests and tqdm (installed automatically)

โšก Quick Start

Command Line

# Install the package
pip install gdlcli

# Download any file
gdlcli --url "https://drive.google.com/file/d/FILE_ID/view" --output myfile.pdf

# Your specific Google Sheets file
gdlcli --url "https://docs.google.com/spreadsheets/d/ID/export" --format xlsx --output spreadsheet.xlsx

Python API

import gdlcli

# Simple download
gdlcli.download("https://drive.google.com/file/d/FILE_ID/view", "output.pdf")

# Advanced usage
downloader = gdlcli.gdlcli()
success = downloader.download_file(
    "https://drive.google.com/file/d/FILE_ID/view",
    "output.pdf",
    resume=True
)

๐Ÿ’ป Command Line Usage

Basic Commands

# Download with auto-detected filename
gdlcli --url "https://drive.google.com/file/d/FILE_ID/view" --auto-name

# Download to specific location
gdlcli --url "https://drive.google.com/file/d/FILE_ID/view" --output ./downloads/myfile.pdf

# Download with progress and resume capability
gdlcli --url "https://drive.google.com/file/d/FILE_ID/view" --output largefile.zip --resume

# Verbose output for debugging
gdlcli --url "https://drive.google.com/file/d/FILE_ID/view" --verbose

Export Google Docs/Sheets/Slides

# Export Google Doc as PDF
gdlcli --url "https://docs.google.com/document/d/DOC_ID/export" --format pdf --output document.pdf

# Export Google Sheet as Excel
gdlcli --url "https://docs.google.com/spreadsheets/d/SHEET_ID/export" --format xlsx --output spreadsheet.xlsx

# Export Google Slides as PowerPoint
gdlcli --url "https://docs.google.com/presentation/d/SLIDES_ID/export" --format pptx --output presentation.pptx

Batch Downloads

# Create a file with URLs (one per line)
echo "https://drive.google.com/file/d/FILE_ID1/view
https://docs.google.com/spreadsheets/d/SHEET_ID/export
https://drive.google.com/file/d/FILE_ID2/view" > urls.txt

# Download all files
gdlcli --batch urls.txt --output-dir ./downloads/

Command Options

gdlcli [OPTIONS]

Required (one of):
  --url URL                Google Drive file URL
  --batch FILE             File containing list of URLs

Options:
  --output, -o PATH        Output file path
  --output-dir PATH        Output directory (default: ./downloads)
  --format FORMAT          Export format (pdf, xlsx, docx, csv, etc.)
  --resume                 Resume interrupted download
  --auto-name              Auto-detect filename from response
  --config FILE            Custom configuration file
  --verbose, -v            Enable verbose logging
  --version                Show version information
  --help                   Show help message

๐Ÿ Python API

Simple Usage

import gdlcli

# Quick download function
success = gdlcli.download(
    url="https://drive.google.com/file/d/FILE_ID/view",
    output="myfile.pdf"
)

Advanced Usage

import gdlcli

# Create downloader instance with custom config
downloader = gdlcli.gdlcli(
    config_file="my_config.json",
    max_retries=5,
    chunk_size=16384
)

# Download with options
success = downloader.download_file(
    url="https://docs.google.com/spreadsheets/d/ID/export",
    output_path="./data/spreadsheet.xlsx",
    format="xlsx",
    resume=True
)

# Batch download
count = downloader.batch_download(
    urls_file="download_list.txt",
    output_dir="./downloads/",
    format="pdf"  # Default format for Google Docs
)

print(f"Downloaded {count} files successfully")

Error Handling

import gdlcli
from gdlcli.downloader import URLError, DownloadError

try:
    downloader = gdlcli.gdlcli()
    downloader.download_file("https://drive.google.com/file/d/INVALID/view", "output.pdf")
except URLError as e:
    print(f"Invalid URL: {e}")
except DownloadError as e:
    print(f"Download failed: {e}")
except Exception as e:
    print(f"Unexpected error: {e}")

๐Ÿ”— Supported URLs

gdlcli automatically handles all Google Drive URL formats:

  • https://drive.google.com/file/d/FILE_ID/view
  • https://drive.google.com/file/d/FILE_ID/view?usp=sharing
  • https://docs.google.com/document/d/FILE_ID/export
  • https://docs.google.com/spreadsheets/d/FILE_ID/export
  • https://docs.google.com/presentation/d/FILE_ID/export
  • https://drive.google.com/open?id=FILE_ID
  • Direct download links with confirmation tokens

๐Ÿ“„ Export Formats

Google Docs

  • pdf - PDF Document
  • docx - Microsoft Word
  • odt - OpenDocument Text
  • rtf - Rich Text Format
  • txt - Plain Text
  • html - HTML
  • epub - EPUB

Google Sheets

  • xlsx - Microsoft Excel
  • ods - OpenDocument Spreadsheet
  • csv - Comma Separated Values
  • tsv - Tab Separated Values
  • pdf - PDF Document
  • html - HTML

Google Slides

  • pptx - Microsoft PowerPoint
  • odp - OpenDocument Presentation
  • pdf - PDF Document
  • txt - Plain Text
  • jpeg - JPEG Images (zip)
  • png - PNG Images (zip)

โš™๏ธ Configuration

Configuration File

Create ~/.gdlcli/config.json or gdlcli_config.json in your project:

{
    "output_dir": "./downloads",
    "chunk_size": 8192,
    "max_retries": 3,
    "retry_delay": 1.0,
    "timeout": 30,
    "verify_ssl": true,
    "auto_create_dirs": true,
    "log_level": "INFO"
}

Environment Variables

export gdlcli_OUTPUT_DIR="./my_downloads"
export gdlcli_MAX_RETRIES="5"
export gdlcli_LOG_LEVEL="DEBUG"

Python Configuration

import gdlcli

# Override configuration
downloader = gdlcli.gdlcli(
    output_dir="./custom_downloads",
    max_retries=5,
    chunk_size=16384,
    log_level="DEBUG"
)

๐Ÿ”ฅ Advanced Usage

Real-World Examples

Download Research Papers

# Create list of paper URLs
echo "https://drive.google.com/file/d/PAPER1_ID/view
https://drive.google.com/file/d/PAPER2_ID/view
https://drive.google.com/file/d/PAPER3_ID/view" > papers.txt

# Download all papers
gdlcli --batch papers.txt --output-dir ./research_papers/ --verbose

Export Multiple Spreadsheets

import gdlcli

spreadsheet_urls = [
    "https://docs.google.com/spreadsheets/d/SHEET1_ID/export",
    "https://docs.google.com/spreadsheets/d/SHEET2_ID/export",
    "https://docs.google.com/spreadsheets/d/SHEET3_ID/export"
]

downloader = gdlcli.gdlcli()

for i, url in enumerate(spreadsheet_urls, 1):
    success = downloader.download_file(
        url=url,
        output_path=f"./data/spreadsheet_{i}.xlsx",
        format="xlsx"
    )
    if success:
        print(f"Downloaded spreadsheet {i}")
    else:
        print(f"Failed to download spreadsheet {i}")

Resume Large Downloads

# Start download (might be interrupted)
gdlcli --url "https://drive.google.com/file/d/LARGE_FILE_ID/view" --output large_dataset.zip

# Resume the download later
gdlcli --url "https://drive.google.com/file/d/LARGE_FILE_ID/view" --output large_dataset.zip --resume

Custom Processing Pipeline

import gdlcli
import pandas as pd

def download_and_process_sheet(url, output_path):
    """Download Google Sheet and process with pandas."""
    
    # Download as Excel file
    downloader = gdlcli.gdlcli()
    success = downloader.download_file(
        url=url,
        output_path=output_path,
        format="xlsx"
    )
    
    if success:
        # Process with pandas
        df = pd.read_excel(output_path)
        print(f"Downloaded sheet with {len(df)} rows")
        return df
    else:
        print("Download failed")
        return None

# Process your specific sheet
df = download_and_process_sheet(
    "https://docs.google.com/spreadsheets/d/ID/export",
    "./data/my_spreadsheet.xlsx"
)

๐Ÿงช Development

Setup Development Environment

git clone https://github.com/mfaeezshabbir/gdlcli.git
cd gdlcli
pip install -e ".[dev]"

Run Tests

pytest
pytest --cov=gdlcli  # With coverage

Code Formatting

black gdlcli/
flake8 gdlcli/
mypy gdlcli/

Package Structure

gdlcli/
โ”œโ”€โ”€ gdlcli/                    # Main package
โ”‚   โ”œโ”€โ”€ __init__.py        # Package initialization
โ”‚   โ”œโ”€โ”€ cli.py             # Command-line interface
โ”‚   โ”œโ”€โ”€ downloader.py      # Core download logic
โ”‚   โ”œโ”€โ”€ utils.py           # Utility functions
โ”‚   โ””โ”€โ”€ config.py          # Configuration management
โ”œโ”€โ”€ tests/                 # Test suite
โ”œโ”€โ”€ examples/              # Usage examples
โ””โ”€โ”€ docs/                  # Documentation

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Guidelines

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure tests pass (pytest)
  6. Format code (black gdlcli/)
  7. Commit changes (git commit -m 'Add amazing feature')
  8. Push to branch (git push origin feature/amazing-feature)
  9. Open a Pull Request

๐Ÿ“Š Performance

gdlcli is optimized for performance:

  • Streaming downloads: Low memory usage even for large files
  • Resume capability: No need to restart failed downloads
  • Concurrent processing: Efficient batch downloads
  • Smart retry logic: Exponential backoff for reliability
  • Progress tracking: Real-time speed and ETA information

๐Ÿ› ๏ธ Troubleshooting

Common Issues

"Could not extract file ID from URL"

  • Ensure the Google Drive URL is public or properly shared
  • Check that the URL format is supported

"Download failed" or "Permission denied"

  • Verify the file is publicly accessible
  • Check if the file requires special permissions
  • Try with --verbose flag for detailed error information

"Module not found" errors

  • Install required dependencies: pip install requests tqdm
  • For development: pip install -e ".[dev]"

Slow downloads

  • Increase chunk size in configuration: "chunk_size": 32768
  • Check your internet connection
  • Try resuming the download: --resume

Getting Help

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Built with โค๏ธ by mfaeezshabbir
  • Inspired by the need for a reliable, cross-platform Google Drive downloader
  • Thanks to the Python community for excellent libraries like requests and tqdm

๐Ÿ“ˆ Changelog

See CHANGELOG.md for detailed release notes.


gdlcli - Making Google Drive downloads simple, fast, and reliable. ๐Ÿš€

Last updated: July 4, 2025

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gdlcli-1.0.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gdlcli-1.0.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file gdlcli-1.0.0.tar.gz.

File metadata

  • Download URL: gdlcli-1.0.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for gdlcli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 750f3d09911d4995ab2907952fff7c5cff7ed1ad6ef1741da434fc5c42069cc2
MD5 36e63002e411e6bfdf242c025fe4b73a
BLAKE2b-256 b02515e4dd70d33d2ec1172c2d6a34734d20e179370c04ef843294d205d654d5

See more details on using hashes here.

File details

Details for the file gdlcli-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: gdlcli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for gdlcli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 742c4ae105b5b392b71dec7d0d35dc0fcc2e9666ec4ea03097e4707bc5b3d722
MD5 71a881c9e21552719421bfdcbdbbe8c1
BLAKE2b-256 2054f4b9cf21bdb526402b71eaeb72aaa372256a6d70ec81d516982e40254cc2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page