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.2.tar.gz (33.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.2-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: youtube_colab_proxy-0.5.2.tar.gz
  • Upload date:
  • Size: 33.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.2.tar.gz
Algorithm Hash digest
SHA256 595e2834fdcaa39f77c403b106a0f0c8b2ceeb75951d0054602c136ff18b0fdd
MD5 18847f2824b7e328dc2f5f9f4a017552
BLAKE2b-256 e25e889138ed06ca9a9c32fcce350bc39e4d6a817ecf766046f635c9173ec294

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for youtube_colab_proxy-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2067bae7c155c308974a673bbc7952a897e0e9fcee255c9e564ba13ee783a9c3
MD5 0e5a1de268a0e527e8e81c51e07713e3
BLAKE2b-256 4ee4e739f92542e4ab4361ec0e7cc2c67e90cf1662a667ae127fc74e7bec456a

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