A fast, lightweight Python package for downloading any file from Google Drive
Project description
gdlcli - Google Drive Loader
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
- Quick Start
- Command Line Usage
- Python API
- Supported URLs
- Export Formats
- Configuration
- Advanced Usage
- Development
- Contributing
- License
๐ง 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+
requestsandtqdm(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/viewhttps://drive.google.com/file/d/FILE_ID/view?usp=sharinghttps://docs.google.com/document/d/FILE_ID/exporthttps://docs.google.com/spreadsheets/d/FILE_ID/exporthttps://docs.google.com/presentation/d/FILE_ID/exporthttps://drive.google.com/open?id=FILE_ID- Direct download links with confirmation tokens
๐ Export Formats
Google Docs
pdf- PDF Documentdocx- Microsoft Wordodt- OpenDocument Textrtf- Rich Text Formattxt- Plain Texthtml- HTMLepub- EPUB
Google Sheets
xlsx- Microsoft Excelods- OpenDocument Spreadsheetcsv- Comma Separated Valuestsv- Tab Separated Valuespdf- PDF Documenthtml- HTML
Google Slides
pptx- Microsoft PowerPointodp- OpenDocument Presentationpdf- PDF Documenttxt- Plain Textjpeg- 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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Ensure tests pass (
pytest) - Format code (
black gdlcli/) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - 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
--verboseflag 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
- ๐ Open an issue for bug reports
- ๐ฌ Start a discussion for questions
- ๐ง Contact: mfaeezshabbir
๐ 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
requestsandtqdm
๐ Changelog
See CHANGELOG.md for detailed release notes.
gdlcli - Making Google Drive downloads simple, fast, and reliable. ๐
Last updated: July 4, 2025
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
750f3d09911d4995ab2907952fff7c5cff7ed1ad6ef1741da434fc5c42069cc2
|
|
| MD5 |
36e63002e411e6bfdf242c025fe4b73a
|
|
| BLAKE2b-256 |
b02515e4dd70d33d2ec1172c2d6a34734d20e179370c04ef843294d205d654d5
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
742c4ae105b5b392b71dec7d0d35dc0fcc2e9666ec4ea03097e4707bc5b3d722
|
|
| MD5 |
71a881c9e21552719421bfdcbdbbe8c1
|
|
| BLAKE2b-256 |
2054f4b9cf21bdb526402b71eaeb72aaa372256a6d70ec81d516982e40254cc2
|