Skip to main content

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

License: MIT Python Version

๐Ÿš€ 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

โœ… 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

ytgrid-1.0.1.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ytgrid-1.0.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

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

Hashes for ytgrid-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c31a19361b3edd4a2a673b86940e328d5171ceb0eb2dddc402221504f5cf8229
MD5 22de46198b70c445afe77f426db00d1e
BLAKE2b-256 debc18d6fe99c0c6bd7bfaa416fdd3d41ac43d020671bc4000f3f8272b4f7a37

See more details on using hashes here.

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

Hashes for ytgrid-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 512ea136e35e325794673a9eaa11fb6806768692a57242ca5b55561e5d82a8d0
MD5 3bc686aa39870bef8e03a1ce38bbcf9b
BLAKE2b-256 f90aba51077a103314b3bc3e7fbb7fceac80a43818a46374457ba6cabb8b9a4a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page