Skip to content

v0.3.3 - Complete Google Drive Download Support

Choose a tag to compare

@zupolgec zupolgec released this 21 Nov 23:47
· 7 commits to main since this release
23159bb

πŸŽ‰ Major Release: Full Google Drive Support

This release fixes critical bugs and adds comprehensive support for all Google Drive file types including Google Workspace documents.

✨ Highlights

πŸ› Critical Bugs Fixed

  • Stream double-consumption bug - Downloads were getting HTML preview pages instead of actual files
  • Form parsing bug - Processing HTML line-by-line broke multi-line forms
  • Language localization bug - Google Docs titles were localized, breaking detection
  • HTTP 500 handling - Now properly retries for Google Workspace documents

πŸš€ New: Auto URL Conversion

No more --fuzzy flag needed! Standard Google Drive URLs just work:

# All of these work automatically now
./bin/gdown 'https://drive.google.com/file/d/ID/view'
./bin/gdown 'https://docs.google.com/document/d/ID/edit'
./bin/gdown 'https://docs.google.com/spreadsheets/d/ID/edit'

πŸ“„ Google Workspace Export

Full support for exporting Google Docs, Sheets, and Slides:

  • Google Docs β†’ DOCX (default) or PDF
  • Google Sheets β†’ XLSX (default)
  • Google Slides β†’ PPTX (default)
# Download as DOCX (default)
./bin/gdown 'https://docs.google.com/document/d/ID/edit'

# Download as PDF
./bin/gdown 'https://docs.google.com/document/d/ID/edit' --format pdf

πŸ›‘οΈ Smart Error Detection

  • Detects Google Drive error/preview pages
  • Prevents downloading HTML garbage
  • Still allows legitimate HTML files
  • Clear error messages

πŸ§ͺ Test Suite

32 tests, 84 assertions, all passing

Integration Tests

Comprehensive tests with permanent public Google Drive links:

  • βœ… Small file (4 bytes)
  • βœ… Large file (100MB)
  • βœ… HTML file
  • βœ… Folder with PDFs
  • βœ… Google Doc (DOCX + PDF)
  • βœ… Google Sheet (XLSX)
  • βœ… Google Slides (PPTX)

All tests use real downloads, no mocks!

πŸ“¦ Installation

composer require zupolgec/gdown-php

πŸ“– Usage

PHP Library

use Zupolgec\GDown\GDown;
use Zupolgec\GDown\FolderDownloader;

// Download file
GDown::download(
    url: 'https://drive.google.com/file/d/FILE_ID/view',
    output: 'file.pdf'
);

// Download Google Doc as DOCX
GDown::download(
    url: 'https://docs.google.com/document/d/DOC_ID/edit',
    output: 'document.docx'
);

// Download Google Doc as PDF
GDown::download(
    url: 'https://docs.google.com/document/d/DOC_ID/edit',
    output: 'document.pdf',
    format: 'pdf'
);

// Download folder
$downloader = new FolderDownloader();
$result = $downloader->downloadFolder(
    url: 'https://drive.google.com/drive/folders/FOLDER_ID'
);

CLI Tool

# Download file (no --fuzzy needed!)
./bin/gdown 'https://drive.google.com/file/d/FILE_ID/view'

# Download folder
./bin/gdown --folder 'https://drive.google.com/drive/folders/FOLDER_ID'

# Download Google Doc as PDF
./bin/gdown 'https://docs.google.com/document/d/DOC_ID/edit' --format pdf

# Get file info
./bin/gdown --info 'https://drive.google.com/file/d/FILE_ID/view'

πŸ”§ What Changed

Files Modified

  • src/Downloader.php - All core fixes
  • src/UrlParser.php - Removed misleading warning
  • tests/IntegrationTest.php - New comprehensive tests
  • tests/DownloaderTest.php - Fixed risky test

Technical Details

  1. Read response body only once (prevent double consumption)
  2. Process entire HTML document (not line-by-line)
  3. Auto-convert /file/d/ URLs to /uc?id= format
  4. Force English with ?hl=en for Google Workspace
  5. Disable Guzzle HTTP exceptions for proper retry logic
  6. Smart error page detection with multiple checks

πŸ“Š Comparison to Python gdown

Feature Python gdown GDown-PHP v0.3.3
File downloads βœ… βœ…
Large files (>100MB) βœ… βœ…
Folder downloads βœ… βœ…
Google Docs export βœ… βœ…
Google Sheets export βœ… βœ…
Google Slides export βœ… βœ…
Auto URL conversion βœ… βœ…
File info preview ❌ βœ… Unique!
Integration tests ❌ βœ… New!

πŸ™ Acknowledgments

Special thanks for manual testing that caught critical bugs automated tests missed!

πŸ“ Full Changelog

v0.3.2...v0.3.3