Skip to content

Repository files navigation

YouTubeKit Server

Remote extraction server for YouTubeKit, running on Cloudflare Workers.

Overview

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.

How It Works

  1. Client establishes WebSocket connection with video ID
  2. Server uses youtubei.js to determine required requests
  3. Server sends HTTP request specifications to client via WebSocket
  4. Client executes requests and returns responses
  5. Server processes responses and extracts stream URLs
  6. Stream URLs are sent back to client

This architecture ensures streams work with the client's IP address and location, avoiding geo-restrictions.

Deployment

Prerequisites

Deploy to Cloudflare Workers

npm install
npm run deploy

For local development:

npm run dev

Rate Limiting

Requests 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.

About

Server to give remote instructions for iOS library `YouTubeKit`

Resources

Stars

24 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages