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 .

To run and test the application, you can use the following commands:

# Run the application
./run_ycp.sh

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-1.0.2.tar.gz (39.0 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-1.0.2-py3-none-any.whl (41.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: youtube_colab_proxy-1.0.2.tar.gz
  • Upload date:
  • Size: 39.0 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-1.0.2.tar.gz
Algorithm Hash digest
SHA256 54326cfb917ad2d08c13d78e66e867126473aa705aadad13462081c8d1b91643
MD5 2a33219b11841e07738b19df4bb0a3d1
BLAKE2b-256 e292a3f872fafff28983ae17223a37852712235ef65d0958eecef3fafb5d616a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for youtube_colab_proxy-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ed96b87f69ca74935644b384cb307ed91a8781f066678833f288350a457c4ade
MD5 38361f169ed428c8e673fd67ed4fc365
BLAKE2b-256 aa0b26722b04af9c7d99ef01ee8a451ea968293b2bf989ceea9f824292651e02

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