Overview
The GDrive Ingest script (gdrive_ingest.sh) is an ultimate cloud ingestor for Google Drive that handles downloading, extracting, organizing, and uploading files with an interactive terminal UI. It excels at music organization with metadata-based folder structures and includes comprehensive support for Telegram downloads.
Key Features
Interactive Folder Selection
Navigate your Google Drive folders with arrow keys - no need to remember folder IDs or names
Live Progress Tracking
Real-time download and upload progress bars with percentage indicators and file size tracking
Smart Music Organization
Automatically organizes music by Artist/Album(Year) structure using ID3 tags and metadata
Telegram Support
Download files from Telegram channels and groups using Telethon API integration
ZIP Extraction
Auto-detects ZIP files and prompts for extraction with smart folder organization
Cover Art Extraction
Automatically extracts and uploads album cover art from music files
Duplicate Detection
Checks for existing files before uploading to prevent duplicates
MD5 Checksums
Generates and displays MD5 checksums for downloaded files
Quick Start
Basic Usage
Interactive Folder Navigation
When run without--folder, an interactive browser opens:
↑/↓- Navigate folders→- Open/enter folder←- Go back to parentEnter- Select folderq- Quit
Command Line Options
Show help message with detailed usage information
Debug mode (dry-run) - shows commands without executing uploads
Destination folder name or ID - skips interactive folder selection
Load URLs from a JSON file containing an array of URLs
URL Formats
The script accepts multiple URL input formats:Configuration
Environment Setup
The script requires a.env file in the same directory with your Google Drive API credentials:
.env
Copy
.env.example to .env and fill in your Google Drive API credentials. See the GDrive Setup guide for details.Telegram Setup (Optional)
For Telegram downloads, you need:- Install Telethon:
pip install telethon - Get API credentials from https://my.telegram.org
- Set environment variables:
See the Telegram Setup guide for detailed instructions on obtaining and configuring Telegram API credentials.
Smart File Organization
The script automatically categorizes and organizes files:Music Files
Music files are organized using metadata tags:Music Organization Features
Music Organization Features
- Reads ID3 tags using ffprobe
- Cleans up website tags and formatting
- Creates Artist/Album(Year) folder structure
- Extracts and uploads cover art automatically
- Prompts before uploading to existing album folders
- Falls back to artist folder if album is unknown
Other File Types
Non-music files are organized by category:- Images →
Images/ - Videos →
Videos/ - Documents/PDFs →
Docs/ - ZIP files →
Folders/zipname/(when extracted) - Others →
Others/
ZIP File Handling
When a ZIP file is detected:- The script prompts: “Extract and upload files? (y/n)”
- If yes: Extracts contents and uploads to
Folders/zipname/ - If no: Uploads the ZIP file as-is to the appropriate category
Example
Progress Display
The script provides rich, color-coded output:Duplicate Detection
Before uploading, the script checks if files already exist in the destination folder:- Queries Google Drive API by filename and parent folder
- Skips files that already exist
- Displays ”⊘ Already exists, skipping” message
Token Caching
Access tokens are cached in~/.gdrive_token and automatically refreshed when expired:
Requirements
The script requires the following system dependencies:- Required
- Optional
curl- For API requests and downloadsjq- JSON parsingunzip- ZIP extractionfile- MIME type detection
Error Handling
Missing Credentials
API Errors
If an API request fails, the script displays detailed error information:Telegram Errors
Related Documentation
For detailed configuration and setup:GDrive Setup
Set up Google Drive API credentials
Telegram Setup
Configure Telegram downloads
File Organization
Learn about folder structure and organization
Interactive Features
Understand the interactive UI