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 for concurrent tasks.
Project description
๐ฅ YTGrid - Hybrid CLI + API for Scalable YT Video Automation
๐ 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 for concurrent tasks.
๐ Table of Contents
- โจ Features
- ๐ Project Structure
- โก Installation
- ๐ฅ๏ธ CLI Usage
- ๐ฅ๏ธ API Usage
- ๐งช Running Tests
- ๐ณ Docker Deployment
- ๐ License
โจ Features
โ New & Improved Features
๐น Hybrid CLI + API โ Use both a command-line interface and a FastAPI-powered REST API.
๐น YT Automation โ Automatically search, play, and loop videos using Selenium.
๐น Session Tracking โ Monitor active sessions in real time using WebSockets.
๐น Parallel Execution โ Run multiple YT automation sessions simultaneously.
๐น Configurable Playback Speed โ Adjust video playback speed dynamically.
๐น WebSocket Real-Time Updates โ Get live session updates.
๐น Optimized Browser Management โ Uses headless Chrome for better performance.
๐น Session Persistence โ Track running and completed sessions efficiently.
๐น Comprehensive Logging โ Logs all activity for debugging and monitoring.
๐ Project Structure
YTGrid/
โโโ ytgrid/ โ Core Python package (installable via pip)
โ โโโ cli.py โ CLI for managing sessions
โ โโโ backend/ โ FastAPI API for remote control
โ โ โโโ main.py โ API entry point
โ โ โโโ routes.py โ API endpoints
โ โ โโโ task_manager.py โ Manages multiprocessing tasks
โ โ โโโ session_store.py โ In-memory session tracking
โ โโโ automation/ โ YT playback automation
โ โ โโโ player.py โ Automates search & playback
โ โ โโโ browser.py โ Manages Selenium WebDriver
โ โโโ utils/ โ Helper functions
โ โ โโโ logger.py โ Logging system
โ โ โโโ config.py โ Configuration settings
โ
โโโ examples/ โ Example scripts
โ โโโ example_cli.py โ CLI example usage
โ โโโ example_api.py โ API example usage
โ
โโโ tests/ โ Unit tests
โ โโโ test_cli.py โ CLI tests
โ โโโ test_api.py โ API tests
โ โโโ test_automation.py โ Automation tests
โ
โโโ setup.py โ Python package setup script
โโโ requirements.txt โ Dependencies
โโโ README.md โ Documentation
โโโ .gitignore โ Ignore unnecessary files
โโโ docker-compose.yml โ Docker deployment
โโโ Dockerfile โ Docker build file
โก Installation
Step 1: Clone the Repository
git clone https://github.com/sandy-sp/ytgrid.git
cd ytgrid
Step 2: Create a Virtual Environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Step 3: Install YTGrid Locally
pip install -e .
Step 4: Verify Installation
ytgrid --help
โ If you see CLI options, installation was successful.
๐ฅ๏ธ CLI Usage
Start a YT Automation Session
ytgrid start --url "https://www.youtube.com/watch?v=OaOK76hiW8I" --speed 1.5 --loops 3
Check Active Sessions
ytgrid status
Stop a Session
ytgrid stop --session_id <num>
๐ฅ๏ธ API Usage
Start API Server
uvicorn ytgrid.backend.main:app --reload
Start a YT 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
}'
Check Session Status
curl -X GET "http://127.0.0.1:8000/status"
Stop a Session
curl -X POST "http://127.0.0.1:8000/sessions/stop" -H "Content-Type: application/json" -d '{"session_id": 1}'
๐งช Running Tests
Run All Tests
pytest tests/
Run a Specific Test
pytest tests/test_api.py
โ If all tests pass, YTGrid is working correctly.
๐ณ Docker Deployment
Build and Run in Docker
docker-compose up --build
Stop Containers
docker-compose down
โ YTGrid will now run in a containerized environment.
๐ License
YTGrid is released under the MIT License.
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-1.0.1.tar.gz.
File metadata
- Download URL: ytgrid-1.0.1.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c31a19361b3edd4a2a673b86940e328d5171ceb0eb2dddc402221504f5cf8229
|
|
| MD5 |
22de46198b70c445afe77f426db00d1e
|
|
| BLAKE2b-256 |
debc18d6fe99c0c6bd7bfaa416fdd3d41ac43d020671bc4000f3f8272b4f7a37
|
File details
Details for the file ytgrid-1.0.1-py3-none-any.whl.
File metadata
- Download URL: ytgrid-1.0.1-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
512ea136e35e325794673a9eaa11fb6806768692a57242ca5b55561e5d82a8d0
|
|
| MD5 |
3bc686aa39870bef8e03a1ce38bbcf9b
|
|
| BLAKE2b-256 |
f90aba51077a103314b3bc3e7fbb7fceac80a43818a46374457ba6cabb8b9a4a
|