Skip to main content

A Python web application that provides a YouTube video streaming proxy with a built-in web player. Designed to work seamlessly in Google Colab environments while also supporting local development and deployment.

Project description

YouTube Colab Proxy

A Python web application that provides a YouTube video streaming proxy with a built-in web player. Designed to work seamlessly in Google Colab environments while also supporting local development and deployment.

Features

🎥 Video Streaming

  • Direct YouTube video streaming through a proxy server
  • Progressive MP4 format support (≤720p) with both audio and video
  • Range request support for video seeking and partial content delivery
  • Automatic format selection using yt-dlp for optimal compatibility

🔍 Search & Discovery

  • YouTube search functionality with keyword-based video discovery
  • Playlist support for YouTube playlists and channel videos
  • Paginated results for efficient browsing

🛡️ Security & Configuration

  • Optional password protection using SHA256 hashing
  • Cookie support for accessing age-restricted or private content
  • Configurable geo-bypass and language settings
  • Outbound proxy support for network routing

Installation

From Source

# Clone the repository
git clone https://github.com/DAN3002/Youtube-Colab-Proxy.git
cd Youtube-Colab-Proxy

# Install in development mode
pip install -e .

Using pip (when published)

pip install youtube-colab-proxy

Quick Start

Command Line Interface

# Start the web server
ycp --serve

# Specify custom host and port
ycp --serve --host 127.0.0.1 --port 8080

# Start with password protection
ycp --serve --password your_password

# Use YouTube cookies for private/age-restricted content
ycp --serve --cookies /path/to/cookies.txt

# Use raw cookie string
ycp --serve --cookies-str "session_token=abc123; other_cookie=xyz"

Google Colab Usage

# Install in Colab
!pip install youtube-colab-proxy

# Start the proxy server
import youtube_colab_proxy
url = youtube_colab_proxy.start()

# The app will automatically:
# 1. Start a Flask server
# 2. Create a public Colab proxy URL
# 3. Display a clickable link in the output

Configuration

Environment Variables

The application can be configured through constants in src/youtube_colab_proxy/const.py:

# Pagination settings
PL_PAGE_SIZE = 8  # Number of items per page

# Security (set to enable password protection)
ADMIN_PASSWORD_SHA256 = "your_sha256_hash_here"

# Localization
YT_LANG = "en-US"  # Language preference
YT_GEO_BYPASS_COUNTRY = "US"  # Country for geo-bypass

# Network settings
OUTBOUND_PROXY = ""  # Optional proxy for outbound requests

Password Protection

To enable password protection:

  1. Generate a SHA256 hash of your password:
import youtube_colab_proxy
hash_value = youtube_colab_proxy.hash_pass("your_password")
print(hash_value)
  1. Set the hash in const.py:
ADMIN_PASSWORD_SHA256 = "your_generated_hash"
  1. Start the server with the password:
ycp --serve --password your_password

API Endpoints

Web Interface

  • GET / - Main web application interface

Video Operations

  • GET /stream?id={video_id} - Stream YouTube video by ID
  • GET /stream?url={youtube_url} - Stream YouTube video by URL

Search & Discovery

  • GET /api/search?q={query}&page={page} - Search YouTube videos
  • GET /api/playlist?url={playlist_url}&page={page} - Get playlist/channel videos
  • GET /api/thumb/{video_id}?q={quality} - Get video thumbnail

Dependencies

  • yt-dlp - YouTube video extraction and metadata
  • Flask - Web application framework
  • youtube-search-python - YouTube search functionality
  • portpicker - Automatic port selection
  • requests - HTTP client for proxy streaming

Development

Setup Development Environment

# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install development dependencies
pip install -U pip setuptools wheel build pytest
pip install -e .

Author

License

Apache License 2.0 - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Disclaimer

This tool is for educational and legitimate use cases only. Please respect YouTube's Terms of Service and copyright laws. Users are responsible for ensuring their usage complies with applicable laws and regulations.

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

youtube_colab_proxy-0.5.0.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

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

youtube_colab_proxy-0.5.0-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

Details for the file youtube_colab_proxy-0.5.0.tar.gz.

File metadata

  • Download URL: youtube_colab_proxy-0.5.0.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for youtube_colab_proxy-0.5.0.tar.gz
Algorithm Hash digest
SHA256 fd206b3debd20fc6fb4aff7a36f6121b6a6706e125dcd099b0ba1bbe5176a2bd
MD5 90a0c64afd706c493e90168d52d86d17
BLAKE2b-256 d54aed96ac96665cadcbf704bf61fb9372419d7bb41907e978c00304d7d03601

See more details on using hashes here.

File details

Details for the file youtube_colab_proxy-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for youtube_colab_proxy-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12d6f486a66431774d3878f3ccab54a4159b8d64d417f08262820a5d2f9216a6
MD5 8cc86a2913e67095c19ff96ee9d135dc
BLAKE2b-256 100fcac1ba75d1cf20884ea3823a64b3aeb052bfc6c632884bad755c26f44a4c

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