Skip to main content

StreamSnapper

PyPI - Version Python Versions License Code Style

Intuitive, high-performance YouTube data extraction library for Python.

🚀 Quick Start📖 API Reference💡 Examples


🌟 Overview

StreamSnapper provides a clean, pythonic interface for extracting YouTube metadata and streams. It wraps yt-dlp with an intuitive object-oriented API, automatic quality enhancements, and robust type safety.

  • Intuitive API: Access data via properties (yt.streams.video.best).
  • Smart Categorization: Videos, audios, and subtitles are automatically sorted and filtered.
  • Modern Tech: Built with pydantic v2 and orjson for high performance.
  • AI Detection: Automatically detects AI-upscaled content.
  • Type Safe: Fully typed for excellent IDE support.

🔧 Installation

uv add streamsnapper

Requirements: Python 3.10+

🚀 Quick Start

Basic Usage

from streamsnapper import YouTube

# automatic extraction on initialization
yt = YouTube("https://www.youtube.com/watch?v=dQw4w9WgXcQ")

# Video Metadata
print(f"Title: {yt.metadata.title}")
print(f"Views: {yt.metadata.view_count}")
print(f"Duration: {yt.metadata.duration_formatted}")

# Stream Access (Automatically sorted by quality)
print(f"Best Video: {yt.streams.video.best.url}")
print(f"Best Audio: {yt.streams.audio.best.url}")

Filtering Streams

StreamSnapper offers a readable fluent interface for filtering:

# specific resolution
stream = yt.streams.video.filter(resolution="1080p").best

# specific codec and frame rate
stream = yt.streams.video.filter(codec="vp9", fps=60).best

# High quality audio
stream = yt.streams.audio.filter(min_bitrate=128).best

💡 Key Features

Intelligent Thumbnails

We automatically filter and deduplicate thumbnails to give you exactly what you need:

  • yt.metadata.thumbnails: A curated list of high-quality thumbnails (maxres, sd, hq).
  • yt.metadata.all_thumbnails: The complete raw list of all available thumbnails.

AI Upscaling Detection

Detects if a stream has been AI-upscaled (e.g., "1080p Premium" or similar enhancements):

if stream.is_ai_upscaled:
    print("This stream is AI upscaled!")

JSON Serialization

All models support high-performance JSON serialization using orjson:

json_data = yt.metadata.to_json()

📖 API Reference

YouTube Class

The main entry point.

yt = YouTube(
    url="https://...",
    cookies=None,      # Optional: CookieFile or CookieBrowser
    logging=False      # Optional: Enable verbose logging
)

Properties:

  • .metadata: VideoInformation object (title, id, description, stats, etc.)
  • .streams: Streams object containing:
    • .video: VideoStreamCollection
    • .audio: AudioStreamCollection
    • .subtitle: SubtitleStreamCollection

VideoStream Model

Represents a single video format. Key attributes:

  • url: Direct download URL.
  • resolution: string (e.g., "1080p").
  • codec: string (e.g., "vp9").
  • bitrate: float (Mbps/Kbps).
  • is_hdr: boolean.
  • is_ai_upscaled: boolean.

🛡️ Authentication (Premium/Age-Restricted)

Access private or age-restricted content using cookies. Cookies are automatically reused across extraction and all subsequent downloads — they are extracted a single time and propagated to every stream, so you never hit unnecessary re-authentication.

from streamsnapper import YouTube, CookieBrowser, CookieFile

# Use cookies from local Chrome browser
yt = YouTube(url, cookies=CookieBrowser.CHROME)

# Use a Netscape-formatted cookie file
yt = YouTube(url, cookies=CookieFile("cookies.txt"))

⬇️ Downloading

Download individual stream

# Download best video-only stream
path = yt.streams.video.best.download(output_path="downloads/")

# Download best audio-only stream
path = yt.streams.audio.best.download(output_path="downloads/")

Default filenames follow the convention:

  • Video-only: <Title> (video-only) [yt-<ID>].ext
  • Audio-only: <Title> (audio-only) [yt-<ID>].ext

Download and merge (video + audio)

YouTube separates high-quality video and audio into distinct streams. Use download_with_audio to merge them automatically with ffmpeg:

video = yt.streams.video.best
audio = yt.streams.audio.best

# Merge and save — requires ffmpeg in PATH
path = video.download_with_audio(audio=audio, output_path="downloads/")
# Result filename: <Title> [yt-<ID>].ext

[!NOTE] ffmpeg must be installed and available in your system PATH for merging to work.

📝 License

MIT License - see LICENSE file.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamsnapper-0.5.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

streamsnapper-0.5.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: streamsnapper-0.5.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for streamsnapper-0.5.0.tar.gz
Algorithm Hash digest
SHA256 de84933cd6d1665dfd23ed8c57d8babd1c1fc5ba94b55760bc3fdb2e76c52727
MD5 5ffc9d93c1bdcce5c6555f5ef149a064
BLAKE2b-256 af68b47168721ce9aac955050c139839fa193148a0ec48733ece290ec89a9a86

See more details on using hashes here.

File details

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

File metadata

  • Download URL: streamsnapper-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for streamsnapper-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec44f9f27dfc308d01e329ee4aaf0bccae1b4f059ed682810f1a01be47584224
MD5 6885299c8651d56d36228efce373eafd
BLAKE2b-256 f2d2eb3a6ae4476ac28a72b850f8ddc905601091625a5e9fc01033cfa6626e4e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page