Anonymous YouTube Content Collector with Tor Integration
GhostTube is a sophisticated, privacy-focused YouTube downloader that routes all traffic through Tor for complete anonymity. It combines DuckDuckGo search with yt-dlp downloads to collect YouTube content without leaving digital footprints.
- Tor Integration: All traffic routed through Tor network
- IP Rotation: Automatic Tor identity switching between requests
- DuckDuckGo Search: No direct YouTube API usage to avoid tracking
- Cookie-less Operation: No persistent tracking mechanisms
- Multi-format Audio: MP3, AAC, FLAC, WAV, OGG, Opus, M4A
- High-quality Video: MP4 format downloads
- Transcript Extraction: Automatic caption/subtitle downloads
- Batch Processing: Queue multiple downloads
- Organized Output: Automatic folder structure creation
- FastAPI Backend: High-performance async API
- Docker Containerized: Easy deployment and isolation
- Web Interface: Modern dark-themed UI
- RESTful API: Full programmatic access
- Health Monitoring: Container health checks and auto-restart
- Responsive Design: Works on desktop and mobile
- Real-time Status: Live download progress and Tor connection status
- Format Selection: Choose audio/video formats and quality
- Search Integration: Built-in YouTube content discovery
βββββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ
β Web Browser ββββββ GhostTube ββββββ Tor Network β
β β β FastAPI β β β
βββββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ
β β
β β
βΌ βΌ
ββββββββββββββββ βββββββββββββββββββ
β yt-dlp β β DuckDuckGo β
β Downloader β β Search β
ββββββββββββββββ βββββββββββββββββββ
β β
β β
βΌ βΌ
ββββββββββββββββ βββββββββββββββββββ
β Local β β YouTube β
β Storage β β Content β
ββββββββββββββββ βββββββββββββββββββ
ghosttube/
βββ README.md # This documentation
βββ docker-compose.yml # Docker Compose configuration
βββ Dockerfile # Container build instructions
βββ fastapi-ghosttube-v-2.py # Main FastAPI application (active)
βββ fastapi-ghosttube-docker.py # Docker-optimized version
βββ index.html # Web interface frontend
| File | Description | Key Features |
|---|---|---|
docker-compose.yml |
Container orchestration | Volume mounts, health checks, networking |
Dockerfile |
Alpine Linux container | Tor setup, Python dependencies, security config |
fastapi-ghosttube-v-2.py |
Main application (650 lines) | API endpoints, Tor integration, download logic |
fastapi-ghosttube-docker.py |
Docker variant (608 lines) | Container-optimized version |
index.html |
Web interface | Modern UI, real-time updates, responsive design |
- Docker & Docker Compose
- 2GB+ available disk space
- Internet connection
git clone https://github.com/yourusername/ghosttube.git
cd ghosttube# Start GhostTube
docker compose up -d
# Check status
docker compose logs -f- Web UI: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Health Check: http://localhost:8000/status
- Open web interface
- Enter search query (e.g., "Blue October music")
- Select formats (Audio: MP3, Video: MP4, Transcripts: Yes)
- Click "Download"
- Check
./downloads/folder for results
services:
ghosttube:
build: .
container_name: ghosttube
ports:
- "8000:8000"
volumes:
- ./downloads:/root/shared:rw # Change download path here
restart: unless-stopped
environment:
- PYTHONUNBUFFERED=1downloads/
βββ audio/
β βββ [query_name]/
β βββ song1.mp3
β βββ song2.flac
β βββ ...
βββ video/
β βββ [query_name]/
β βββ video1.mp4
β βββ ...
βββ transcripts/
βββ [query_name]/
βββ video1.en.vtt
βββ ...
| Format | Quality | File Size | Compatibility |
|---|---|---|---|
| MP3 | Good | Medium | Universal |
| AAC | Better | Medium | Modern devices |
| FLAC | Lossless | Large | Audiophile |
| WAV | Uncompressed | Largest | Professional |
| OGG | Good | Small | Open source |
| Opus | Excellent | Smallest | Streaming |
| M4A | Good | Medium | Apple devices |
Root endpoint with API information
{
"name": "YouTube Collector Agent API",
"version": "2.1",
"description": "Anonymous YouTube content collector"
}Check API and Tor connection status
{
"message": "YouTube Collector API running",
"tor_connected": true,
"current_ip": "192.42.116.195",
"timestamp": "2024-01-15T10:30:00Z"
}Search YouTube content via DuckDuckGo
Request:
{
"query": "Blue October music",
"max_results": 10
}Response:
{
"query": "Blue October music",
"results": [
"https://youtube.com/watch?v=...",
"https://youtube.com/watch?v=..."
],
"count": 10
}Download YouTube content
Request:
{
"query": "Blue October Into The Ocean",
"audio": true,
"video": false,
"transcripts": true,
"audio_format": "mp3",
"max_results": 5
}Response:
{
"success": true,
"message": "Download completed successfully",
"results": [
{
"url": "https://youtube.com/watch?v=...",
"title": "Into The Ocean",
"status": "completed",
"files": ["audio/Blue_October/Into_The_Ocean.mp3"]
}
],
"download_path": "/root/shared/audio/Blue_October/"
}Manually rotate Tor identity
{
"success": true,
"old_ip": "192.42.116.195",
"new_ip": "185.220.101.42",
"message": "Tor identity rotated successfully"
}- Clone and setup:
git clone https://github.com/Mikewhodat/GhostTube.git
cd ghosttube- Install Tor (Ubuntu/Debian):
sudo apt update
sudo apt install tor
sudo service tor start- Configure Tor (
/etc/tor/torrc):
SocksPort 127.0.0.1:9050
ControlPort 127.0.0.1:9051
CookieAuthentication 1
- Install Python dependencies:
pip install fastapi uvicorn requests[socks] stem yt-dlp pydantic- Run development server:
python fastapi-ghosttube-v-2.py# Test Tor connection
curl --socks5-hostname 127.0.0.1:9050 https://check.torproject.org/api/ip
# Test API endpoints
curl http://localhost:8000/status
curl -X POST http://localhost:8000/search -H "Content-Type: application/json" -d '{"query":"test","max_results":5}'- Base Image:
python:3.12-alpine - Size: ~200MB compressed
- Ports: 8000 (HTTP API)
- Volumes:
/root/shared(downloads) - Health Check: 30s interval, 3 retries
# Build container
docker build -t ghosttube .
# Run manually
docker run -d -p 8000:8000 -v $(pwd)/downloads:/root/shared:rw ghosttubePYTHONUNBUFFERED=1 # Real-time log streaming- No Direct YouTube API: Bypasses YouTube's tracking
- Tor Routing: All traffic through Tor network
- No Cookies: Stateless operation
- IP Rotation: Regular identity changes
- Local Storage: Downloads stored locally
- Container runs with minimal privileges
- No sensitive data persistence
- Regular security updates via Alpine base
- Isolated network namespace
SocksPort 127.0.0.1:9050 # SOCKS proxy
ControlPort 127.0.0.1:9051 # Control port
CookieAuthentication 1 # Authentication
Log notice file /var/log/tor/log
- RAM: 256MB minimum, 512MB recommended
- CPU: 1 core, 2+ cores recommended
- Storage: 1GB+ free space for downloads
- Network: Stable internet connection
- Container Startup: ~15-30 seconds
- Audio Download: ~30-60 seconds per song
- Video Download: ~1-5 minutes per video
- Search Response: ~2-5 seconds
- Tor Identity Rotation: ~10-15 seconds
# Check logs
docker compose logs ghosttube
# Restart container
docker compose restart ghosttube# Verify Tor is running in container
docker compose exec ghosttube ps aux | grep tor
# Check Tor logs
docker compose exec ghosttube cat /var/log/tor/log# Check volume mount
docker compose exec ghosttube ls -la /root/shared/
# Verify permissions
sudo chown -R $USER:$USER ./downloads/# Check port binding
docker compose ps
netstat -tlnp | grep 8000
# Test API directly
curl http://localhost:8000/status# Container shell access
docker compose exec ghosttube sh
# Real-time logs
docker compose logs -f ghosttube
# Check Tor connection
docker compose exec ghosttube wget -qO- https://check.torproject.org/api/ip- Fork the repository
- Create feature branch:
git checkout -b feature-name - Make changes and test
- Submit pull request
- Follow PEP 8 for Python code
- Add docstrings for new functions
- Update README for new features
- Test with Docker before submitting
- Use GitHub issues
- Include logs and system info
- Provide reproduction steps
- Educational Purpose: This tool is for educational and personal use
- Respect Copyright: Only download content you have permission to use
- YouTube ToS: Be aware of YouTube's Terms of Service
- Local Laws: Comply with your local copyright and privacy laws
- Users are responsible for their usage
- Developers not liable for misuse
- Tool provided "as-is" without warranty
This project is licensed under the MIT License - see the LICENSE file for details.
- FastAPI - Modern Python web framework
- yt-dlp - YouTube downloader
- Tor - Anonymous communication
- Docker - Containerization
- Alpine Linux - Lightweight container base
- Mike Jones- Initial development and maintenance
I would love to have more contributors.
- GitHub Issues: Report bugs or request features
- Documentation: Check this README and API docs at
/docs - Community: Join discussions in GitHub Discussions
π΅οΈ Stay Anonymous: GhostTube helps protect your privacy, but always be aware of your local laws and regulations.
V1 code code does not contain a cookies.txt captured from a signed in account from a throwaway email.Obviously future versions will contain that
if you are experiencing issues where the fast API is not loading the reason for that is you need to change the CMD for
Tor a little longer. Currently, it is 30 seconds, but the bootstrap needs time to actually complete for connection.
So, if you're getting this cycle of the fast, API attempting to load and failing to load the reason for that is because I've set this script up to reject. Standard networking configurations. the good news is, it's all self-contained within the container.
CMD ["sh", "-c", "echo 'Starting Tor...' && tor -f /etc/tor/torrc & sleep 60 && echo 'Starting FastAPI...' && python fastapi-ghosttube-v-2.py"]