or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

data-validation.mdindex.mdoptions-configuration.mdplugin-system.mdsession-management.mdstream-access.mdutilities.md
tile.json

tessl/pypi-streamlink

Command-line utility and Python library for extracting video streams from various streaming services

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/streamlink@7.5.x

To install, run

npx @tessl/cli install tessl/pypi-streamlink@7.5.0

index.mddocs/

Streamlink

A command-line utility and Python library for extracting video streams from various streaming services (Twitch, YouTube, etc.) and piping them into video players. Streamlink provides a plugin-based architecture that allows easy addition of support for new streaming services, advanced stream quality selection, and both CLI and API interfaces for different use cases.

Package Information

  • Package Name: streamlink
  • Language: Python
  • Installation: pip install streamlink
  • Requirements: Python >= 3.9

Core Imports

import streamlink

Common for direct stream extraction:

from streamlink import streams

For advanced usage with sessions:

from streamlink import Streamlink

Basic Usage

import streamlink

# Simple stream extraction using the convenience function
url = "https://www.twitch.tv/example_channel"
streams_dict = streamlink.streams(url)

# Select best quality stream
if streams_dict:
    best_stream = streams_dict['best']
    print(f"Stream URL: {best_stream.url}")
    
    # Open stream for reading
    with best_stream.open() as stream_io:
        data = stream_io.read(1024)
        print(f"Read {len(data)} bytes")

# Advanced usage with session configuration
session = streamlink.Streamlink()
session.set_option('http-timeout', 30)
session.set_option('http-headers', {'User-Agent': 'My Custom Agent'})

streams_dict = session.streams(url)

Architecture

Streamlink's architecture centers around these key components:

  • Session: The main Streamlink class manages plugins, HTTP sessions, and configuration options
  • Plugins: Extensible plugin system with URL pattern matching for different streaming services
  • Streams: Different stream types (HTTP, HLS, DASH, Muxed) handle various streaming protocols
  • Options: Flexible configuration system with validation and type checking
  • Validation: Schema-based validation system for parsing and data validation

This design allows Streamlink to support hundreds of streaming services through a unified interface while providing both simple convenience functions and advanced customization capabilities.

Capabilities

Session Management

Central session management for configuring HTTP behavior, plugin loading, and stream extraction. The Streamlink class coordinates all operations and maintains state across plugin interactions.

class Streamlink:
    def __init__(self, options=None, *, plugins_builtin=True, plugins_lazy=True): ...
    def set_option(self, key: str, value): ...
    def get_option(self, key: str): ...
    def resolve_url(self, url: str, follow_redirect=True): ...
    def resolve_url_no_redirect(self, url: str): ...
    def streams(self, url: str, options=None, **params): ...
    
    # Properties
    @property
    def version(self): ...
    @property
    def localization(self): ...
    
    # Session attributes
    http: HTTPSession
    options: StreamlinkOptions
    plugins: StreamlinkPlugins

class StreamlinkOptions(Options): ...

def streams(url: str, **params):
    """Convenience function using default session"""

Session Management

Stream Access

Multiple stream types supporting different protocols including HTTP streams, HLS (HTTP Live Streaming), DASH (Dynamic Adaptive Streaming), and muxed streams combining multiple tracks.

class Stream:
    def open(self): ...
    def to_url(self): ...

class StreamIO(io.IOBase): ...

class HTTPStream(Stream):
    def __init__(self, session, url, buffered=True, **kwargs): ...

class HLSStream(Stream): ...
class MuxedHLSStream(Stream): ...
class DASHStream(Stream): ...
class MuxedStream(Stream):
    def __init__(self, session, *substreams, **options): ...

# Stream IO Wrappers
class StreamIOWrapper: ...
class StreamIOIterWrapper(StreamIOWrapper): ...
class StreamIOThreadWrapper(StreamIOWrapper): ...

Stream Access

Plugin System

Extensible plugin architecture for adding support for new streaming services. Plugins use decorators to define URL patterns and command-line arguments.

class Plugin:
    def __init__(self, session, url, options=None): ...
    def streams(self, stream_types=None, sorting_excludes=None): ...

def pluginmatcher(pattern, priority=20, name=None): ...
def pluginargument(name, **kwargs): ...

# Plugin configuration classes
class PluginArguments: ...
class PluginOptions(Options): ...

# Priority constants
HIGH_PRIORITY = 30
NORMAL_PRIORITY = 20
LOW_PRIORITY = 10
NO_PRIORITY = 0

Plugin System

Options and Configuration

Flexible options system for configuring HTTP behavior, stream preferences, and plugin settings with getter/setter mappings and validation.

class Options(dict):
    def __init__(self, defaults=None): ...
    def get(self, key: str): ...
    def set(self, key: str, value): ...
    def update(self, options): ...
    def clear(self): ...

Options and Configuration

Data Validation

Schema-based validation system for parsing HTML, JSON, XML and validating data structures with combinators and type-specific validators.

def validate(obj, schema): ...

# Schema combinators  
def all(*schemas): ...
def any(*schemas): ...
def none_or_all(*schemas): ...
def optional(schema): ...
def transform(func, *schemas): ...
def list(schema): ...
def union(*schemas): ...
def union_get(*schemas): ...
def regex(pattern, **kwargs): ...
def xml_element(tag=None, **kwargs): ...

# Data access validators
def attr(attr, schema, default=None): ...
def get(item, schema, default=None): ...

# String validators
def contains(item): ...
def startswith(prefix): ...
def endswith(suffix): ...
def length(min_len, max_len=None): ...
def getattr(attr, default=None): ...
def hasattr(attr): ...
def filter(func): ...
def map(func): ...

# Parsing validators
def url(**kwargs): ...
def parse_html(**kwargs): ...
def parse_json(**kwargs): ...
def parse_xml(**kwargs): ...
def parse_qsd(**kwargs): ...

# XML validators
def xml_find(tag): ...
def xml_findall(tag): ...
def xml_findtext(tag): ...
def xml_xpath(expression): ...
def xml_xpath_string(expression): ...

Data Validation

Utilities

URL manipulation, parsing utilities, caching, and system integration functions for common operations in plugin development.

# URL utilities
def absolute_url(base, url): ...
def update_qsd(url, **params): ...
def update_scheme(scheme, url, force=False): ...

# Parsing utilities  
def parse_html(data, **kwargs): ...
def parse_json(data, **kwargs): ...
def search_dict(obj, key): ...

# System utilities
class NamedPipe: ...
class LRUCache: ...

Utilities

Exception Hierarchy

class StreamlinkError(Exception): ...
class PluginError(StreamlinkError): ...
class FatalPluginError(PluginError): ...
class NoPluginError(StreamlinkError): ...
class NoStreamsError(StreamlinkError): ...
class StreamError(StreamlinkError): ...
class StreamlinkWarning(UserWarning): ...
class StreamlinkDeprecationWarning(StreamlinkWarning): ...

All Streamlink-specific exceptions inherit from StreamlinkError, allowing for comprehensive error handling in applications using the library.