Remote extraction server for YouTubeKit, running on Cloudflare Workers.
This server enables remote YouTube stream extraction when local extraction fails. It uses a WebSocket-based architecture where the server orchestrates HTTP requests through the client device, ensuring stream URLs remain playable on the client's network.
- Client establishes WebSocket connection with video ID
- Server uses youtubei.js to determine required requests
- Server sends HTTP request specifications to client via WebSocket
- Client executes requests and returns responses
- Server processes responses and extracts stream URLs
- Stream URLs are sent back to client
This architecture ensures streams work with the client's IP address and location, avoiding geo-restrictions.
- Cloudflare Workers account
- Wrangler CLI installed
npm install
npm run deployFor local development:
npm run devRequests are limited per app ID (X-AppID-v1) using a Durable Object with anchored windows:
- daily window starts at first request and runs for 24h
- weekly window starts at first request and runs for 7d
- when a window expires, the next request starts a new window
Configure limits using environment variables in wrangler.toml:
RATE_LIMIT_DAILY_REQUESTS: max requests per app ID in each 24h window.RATE_LIMIT_WEEKLY_REQUESTS: max requests per app ID in each 7d window.