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.1.tar.gz (11.9 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.1-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ytgrid-2.0.1.tar.gz
  • Upload date:
  • Size: 11.9 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.1.tar.gz
Algorithm Hash digest
SHA256 f1e8c007cb88869d872700959aff239ea5587b8a618528ac003502efd94b3551
MD5 adede65bfc0d5f2f23aa1bbe1f6a66f9
BLAKE2b-256 762b222f995641a59b423ce79f733f4073187486341fc80b99458eb074d1c281

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ytgrid-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ef3a5c8df71b9c0121ab57cadb11c43c562f1c86f6fcfbb27376d7328ec2a95
MD5 e31545b8612585f8cbb2b41f423137ee
BLAKE2b-256 067114da136cda2a425d340f48b7aefd66911d2d1a3e4effe613f14257e5f2b9

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