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/Celery for concurrent tasks.

Project description

🎥 YTGrid - Hybrid CLI + API for Scalable YT Automation

License: MIT Python Version

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:

  1. Fork the repository
  2. Create a feature branch
git checkout -b feature/my-feature
  1. Commit your changes
  2. 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

ytgrid-2.0.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

ytgrid-2.0.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file ytgrid-2.0.0.tar.gz.

File metadata

  • Download URL: ytgrid-2.0.0.tar.gz
  • Upload date:
  • Size: 11.6 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

Hashes for ytgrid-2.0.0.tar.gz
Algorithm Hash digest
SHA256 adc2a12b71048f108402feeafed0c98eceb8b91b5d96af565bb12fb12bc7f554
MD5 21d1042a63e3229dbbd677c642e2d33a
BLAKE2b-256 003e274dadad5a1331f53d67a4411d4f2fd81ef175c52ee22e01f916b784b5c7

See more details on using hashes here.

File details

Details for the file ytgrid-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: ytgrid-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 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

Hashes for ytgrid-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3f1bab9d46cd456a5e3c9f5c27913f7581eae895d9a82c0b604f7b3731a3ee6
MD5 55eb327e5839607b1701408675d15d2b
BLAKE2b-256 cb301ff60eb73e39225fe68825d99efa07cea70e486dd48c6f421fad0409475d

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