YTGrid is a powerful, scalable, and flexible YT automation tool that enables looped playback, remote control, and real-time tracking using a hybrid CLI + API architecture. It integrates FastAPI for REST API control, Selenium for browser automation, and Python multiprocessing/Celery for concurrent tasks.
Project description
🎥 YTGrid - Hybrid CLI + API for Scalable YT Automation
YTGrid is a powerful, scalable, and flexible YT automation tool designed to enable looped playback, remote control, and real-time tracking using a hybrid CLI + API architecture. It provides:
- A RESTful API built with FastAPI
- Browser automation using Selenium (with headless Chrome)
- Concurrent and asynchronous task execution via Celery (or Python multiprocessing)
- Real-time session updates using Server-Sent Events (SSE)
- A user-friendly CLI built with Typer
📌 Features
✅ Hybrid Interface – Manage automation via CLI + API
✅ Scalable Execution – Run multiple browser instances in parallel
✅ Configurable Automation – Set playback speed, loop count, and more
✅ Celery Integration – Supports both multiprocessing & Celery for task execution
✅ Lightweight Installation – Available as a PyPI package
📦 Installation (PyPI)
YTGrid is available on PyPI. Install it using:
pip install ytgrid
Requirements:
- Python 3.8+
- Google Chrome
- ChromeDriver (Automatically managed by
webdriver-manager) - Redis (if using Celery)
🚀 CLI Usage
YTGrid provides a command-line interface (CLI) to manage automation.
Start a Session
ytgrid start --session-id test123 --url "https://www.youtube.com/watch?v=UXFBUZEpnrc" --speed 1.5 --loops 3
Check Active Sessions
ytgrid status
Stop a Session
ytgrid stop --session-id test123
Detailed Usage Instructions
ytgrid --help
🖥️ API Usage
YTGrid provides a FastAPI-based REST API.
1️⃣ Start a Session
curl -X POST "http://127.0.0.1:8000/sessions/start" \
-H "Content-Type: application/json" \
-d '{"url": "https://www.youtube.com/watch?v=OaOK76hiW8I", "speed": 1.5, "loop_count": 3}'
2️⃣ Check Active Sessions
curl -X GET "http://127.0.0.1:8000/sessions/status"
3️⃣ Stop a Session
curl -X POST "http://127.0.0.1:8000/sessions/stop" \
-H "Content-Type: application/json" \
-d '{"session_id": 1}'
🛠️ Configuration
YTGrid is configurable via environment variables.
Create a .env file in the project root:
YTGRID_HEADLESS_MODE=True
YTGRID_DEFAULT_SPEED=1.0
YTGRID_DEFAULT_LOOP_COUNT=1
YTGRID_MAX_SESSIONS=5
YTGRID_USE_TEMP_USER_DATA=True
YTGRID_BROWSER_TIMEOUT=20
YTGRID_USE_CELERY=False # Set to True if using Celery
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/0
🧪 Running Tests
Run unit tests using pytest:
pytest tests/
To run a specific test:
pytest tests/test_api.py
📜 License
This project is licensed under the MIT License.
🌍 Contributing
Contributions are welcome!
To contribute:
- Fork the repository
- Create a feature branch
git checkout -b feature/my-feature
- Commit your changes
- Push to your fork and create a PR
📖 Additional Resources
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
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 ytgrid-2.0.3.tar.gz.
File metadata
- Download URL: ytgrid-2.0.3.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.8 Linux/6.8.0-1020-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d93894026f5c867b8e77a750bc649dfe6bf5ff593e28683f29a6b14c71affc02
|
|
| MD5 |
66ce492ece56ef2d7fcec29b35823094
|
|
| BLAKE2b-256 |
1a82cd22f05c8e876b90e61e664c57b70b1652d6790f540e4f2e149f1945e367
|
File details
Details for the file ytgrid-2.0.3-py3-none-any.whl.
File metadata
- Download URL: ytgrid-2.0.3-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.8 Linux/6.8.0-1020-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07cf953a7e839d93080d59dddac2eef9ae800049e67d45c77d77a80a66c5d66d
|
|
| MD5 |
19d1b014631732f50b46f759ab61a630
|
|
| BLAKE2b-256 |
09ff6881fb6997150d0395fba27397cfccba3c245c51145466ade725d223632c
|