![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
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.
YTGrid is a powerful, scalable, and flexible YouTube 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 supports concurrent task execution via Python multiprocessing or Celery.
✅ 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 multiprocessing & Celery (optional)
✅ Real-time Updates – Monitor active sessions via WebSocket/SSE
✅ Lightweight Installation – Available as a PyPI package & Docker image
✅ Clearer Installation Instructions (PyPI, Docker, Dev Setup)
✅ Expanded CLI & API Examples (With Expected Outputs)
✅ Easier Configuration Guide (Using .env
File)
✅ Structured Contribution Guidelines (For Developers)
✅ Added Future Roadmap (Keeps Users Informed)
YTGrid is available on PyPI. Install it using:
pip install ytgrid
docker pull sandy1sp/ytgrid:latest
docker run -p 8000:8000 sandy1sp/ytgrid:latest
git clone https://github.com/sandy-sp/ytgrid.git
cd ytgrid
poetry install
Requirements:
webdriver-manager
, but the Chrome browser itself is not bundled with YTGrid.webdriver-manager
YTGrid provides a command-line interface (CLI) to manage automation sessions.
ytgrid start --session-id test123 --url "https://www.youtube.com/watch?v=UXFBUZEpnrc" --speed 1.5 --loops 3
💡 This command starts an automation session with a specified session ID, URL, speed, and loop count.
ytgrid status
✅ This command displays all active sessions along with their current loop progress.
ytgrid stop --session-id test123
🚀 Stops the automation session with the given session-id
.
ytgrid batch tasks.csv --delimiter ","
tasks.csv
) should have a header row with columns: session_id, url, speed, loops, task_type
.ytgrid toggle-celery
🔄 Enables or disables Celery mode without manually editing the .env
file.
YTGrid can be deployed using Docker, which allows you to run the application along with its dependencies in a containerized environment. We offer two primary ways to obtain the Docker image:
Use the provided Dockerfile to build a lean, production-ready image that installs YTGrid from PyPI and includes all necessary dependencies (including Google Chrome).
docker build -t ytgrid .
Then, run the container:
docker run -p 8000:8000 ytgrid
Or, for an orchestrated setup with Redis (for optional Celery support), use docker-compose:
docker-compose up --build
You can also pull the latest prebuilt Docker image directly from our registries:
Pull the image from Docker Hub:
docker pull sandy1sp/ytgrid:latest
Then run the container:
docker run -p 8000:8000 sandy1sp/ytgrid:latest
Alternatively, pull the image from GHCR:
docker pull ghcr.io/sandy-sp/ytgrid:latest
Then run the container:
docker run -p 8000:8000 ghcr.io/sandy-sp/ytgrid:latest
YTGrid supports distributed task processing using Celery. Although Celery is disabled by default in the PyPI release, you can enable it in a Docker environment for advanced use cases. When Celery is enabled, a Redis server is required as the message broker and result backend.
In the docker-compose.yml
file, Redis is defined as a service. To enable Celery:
Set Environment Variables:
Ensure that the following environment variables are set (as shown in the docker-compose.yml
):
- YTGRID_USE_CELERY=True
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
Run docker-compose:
Start the services with:
docker-compose up --build
This will start both the YTGrid container and the Redis container. The YTGrid application will then use Celery with Redis for task management.
Verify Celery Operation:
You can run a Celery worker by executing:
docker exec -it ytgrid_api celery -A ytgrid.backend.celery_app worker --loglevel=info
This worker will connect to the Redis server and process tasks. You can also use monitoring tools like Flower to visualize task processing.
For those who install YTGrid via pip, Celery is disabled by default to keep the package lean. If you want to enable Celery locally, you must:
YTGRID_USE_CELERY
setting (using the CLI command ytgrid toggle-celery
or by editing your .env
file).YTGrid provides a FastAPI-based REST API.
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}'
curl -X GET "http://127.0.0.1:8000/sessions/status"
curl -X POST "http://127.0.0.1:8000/sessions/stop" \
-H "Content-Type: application/json" \
-d '{"session_id": 1}'
YTGrid is configurable via environment variables. Create a .env
file in the project root with the following content:
# General settings
YTGRID_HEADLESS_MODE=True
YTGRID_DEFAULT_SPEED=1.0
YTGRID_DEFAULT_LOOP_COUNT=1
YTGRID_MAX_SESSIONS=5
# Real-time updates
YTGRID_REALTIME_UPDATES=False
YTGRID_WEBSOCKET_SERVER_URL=ws://web:8000/ws
# Browser settings
YTGRID_USE_TEMP_USER_DATA=True
YTGRID_BROWSER_TIMEOUT=20
# Celery configuration (Celery is off by default in the PyPI release)
YTGRID_USE_CELERY=False
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/0
# Session storage: Options include in-memory (default) or persistent storage (e.g., sqlite)
YTGRID_SESSION_STORAGE=sqlite
Note: For local PyPI usage, ensure Google Chrome is installed. For Docker deployments, the image includes Chrome installation.
We have an exciting roadmap ahead for YTGrid. Some of the planned enhancements include:
Advanced Dynamic Scheduling:
Implement adaptive scheduling algorithms that dynamically adjust the number of parallel sessions based on real-time system metrics (e.g., CPU and memory usage). This will help optimize resource utilization without the need for complex predictive models.
Expanded Automation Capabilities:
In addition to the current "video" task type, we plan to add support for:
These enhancements will broaden the automation options available to users.
Decoupled Microservices Architecture:
Separate the API gateway from the automation workers into distinct services, allowing for independent scaling and improved fault tolerance. We plan to explore container orchestration using Kubernetes for enhanced scalability in cloud environments.
User Interface Enhancements:
Develop a web-based dashboard for real-time monitoring and control of automation sessions, making it easier for users to manage tasks without relying solely on the CLI.
Extended Batch Processing Options:
Support additional input formats such as JSON and Excel for batch job submissions, along with interactive CLI prompts to simplify the process.
These planned features aim to make YTGrid more robust, scalable, and user-friendly, ensuring that it evolves to meet the diverse needs of automation tasks.
This project is licensed under the MIT License.
Contributions are welcome!
To contribute:
git checkout -b feature/my-feature
FAQs
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.
We found that ytgrid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.