You are reading the documentation for the in-development version of Streamlink.
Session¶
- class streamlink.session.Streamlink(options=None, *, plugins_builtin=True, plugins_lazy=True)¶
Bases:
objectThe Streamlink session is used to load and resolve plugins, and to store options used by plugins and stream implementations.
- Parameters:
options (Mapping[str, Any] | Options | None) -- Custom options
plugins_builtin (bool) -- Whether to load built-in plugins or not
plugins_lazy (bool) -- Load built-in plugins lazily. This option falls back to loading all built-in plugins if the pre-built plugin JSON metadata is not available (e.g. in editable installs) or is invalid.
- http: HTTPSession¶
An instance of Streamlink's
requests.Sessionsubclass. Used for any kind of HTTP request made by plugin and stream implementations.
- options: StreamlinkOptions¶
Options of this session instance.
StreamlinkOptionsis a subclass ofOptionswith special getter/setter mappings.
- plugins: StreamlinkPlugins¶
Plugins of this session instance.
- set_option(key, value)¶
Sets general options used by plugins and streams originating from this session object.
This is a convenience wrapper for
self.options.set().Please see
StreamlinkOptionsfor the available options.- Parameters:
key (str) -- key of the option
value (Any) -- value to set the option to
- Return type:
None
- get_option(key)¶
Returns the current value of the specified option.
This is a convenience wrapper for
self.options.get().Please see
StreamlinkOptionsfor the available options.- Parameters:
key (str) -- key of the option
- Return type:
Any
- resolve_url(url, follow_redirect=True)¶
Attempts to find a plugin that can use this URL.
The default protocol (https) will be prefixed to the URL if not specified.
Return values of this method are cached via
functools.lru_cache().- Parameters:
url (str) -- a URL to match against loaded plugins
follow_redirect (bool) -- follow redirects
- Raises:
NoPluginError -- on plugin resolve failure
- Returns:
A tuple of plugin name, plugin class and resolved URL
- Return type:
tuple[str, type[Plugin], str]
- resolve_url_no_redirect(url)¶
Attempts to find a plugin that can use this URL.
The default protocol (https) will be prefixed to the URL if not specified.
- Parameters:
url (str) -- a URL to match against loaded plugins
- Raises:
NoPluginError -- on plugin resolve failure
- Returns:
A tuple of plugin name, plugin class and resolved URL
- Return type:
tuple[str, type[Plugin], str]
- streams(url, options=None, **params)¶
Attempts to find a plugin and extracts streams from the url if a plugin was found.
- Parameters:
url (str) -- a URL to match against loaded plugins
options (Options | None) -- Optional options instance passed to the resolved plugin
params -- Additional keyword arguments passed to
Plugin.streams()
- Raises:
NoPluginError -- on plugin resolve failure
- Returns:
A
dictof stream names andStreaminstances
- get_plugins()¶
Returns the loaded plugins of this session.
Deprecated in favor of
plugins.get_loaded().
- load_builtin_plugins()¶
Loads Streamlink's built-in plugins.
Deprecated in favor of using the
plugins_builtinkeyword argument.
- load_plugins(path)¶
Loads plugins from a specific path.
Deprecated in favor of
plugins.load_path().- Parameters:
path (str)
- Return type:
bool
- class streamlink.session.options.StreamlinkOptions(session)¶
Bases:
OptionsStreamlink's session options.
The following options can be accessed using the
Streamlink.get_option()andStreamlink.set_option()methods, as well as the regularget()andset()methods of thisOptionssubclass.key
type
default
description
user-input-requester
UserInputRequester | NoneNoneInstance of
UserInputRequesterto collect input from the user at runtimeno-plugin-cache
boolFalseDisable the plugin key-value store
locale
strsystem locale
Locale setting, in the RFC 1766 format, e.g.
en_USores_ESinterface
str | NoneNoneNetwork interface address
ipv4
boolFalseResolve address names to IPv4 only, overrides
ipv6ipv6
boolFalseResolve address names to IPv6 only, overrides
ipv4http-proxy
str | NoneNoneProxy address for all HTTP/HTTPS requests
https-proxy (deprecated)
str | NoneNoneProxy address for all HTTP/HTTPS requests
http-cookies
dict[str, str] | str{}A
dictor a semicolon;delimitedstrof cookies to add to each HTTP/HTTPS request, e.g.foo=bar;baz=quxhttp-headers
dict[str, str] | str{}A
dictor a semicolon;delimitedstrof headers to add to each HTTP/HTTPS request, e.g.foo=bar;baz=quxhttp-query-params
dict[str, str] | str{}A
dictor an ampersand&delimitedstrof query string parameters to add to each HTTP/HTTPS request, e.g.foo=bar&baz=quxhttp-trust-env
boolTrueTrust HTTP settings set in the environment, such as environment variables (
HTTP_PROXY, etc.) and~/.netrcauthenticationhttp-ssl-verify
boolTrueVerify TLS/SSL certificates
http-disable-dh
boolFalseDisable TLS/SSL Diffie-Hellman key exchange
http-ssl-cert
str | tuple | NoneNoneTLS/SSL certificate to use, can be either a .pem file (
str) or a .crt/.key pair (tuple)http-timeout
float20.0General timeout used by all HTTP/HTTPS requests, except the ones covered by other options
ringbuffer-size
int16777216(16 MiB)The size of the internal ring buffer used by most stream types
mux-subtitles
boolFalseMake supported plugins mux available subtitles into the output stream
stream-segment-attempts
int3Number of segment download attempts in segmented streams
stream-segment-threads
int1The size of the thread pool used to download segments in parallel
stream-segment-timeout
float10.0Segment connect and read timeout
stream-timeout
float60.0Timeout for reading data from stream
hls-live-edge
int3Number of segments from the live position of the HLS stream to start reading
hls-live-restart
boolFalseSkip to the beginning of a live HLS stream, or as far back as possible
hls-start-offset
float0.0Number of seconds to skip from the beginning of the HLS stream, interpreted as a negative offset for livestreams
hls-duration
float | NoneNoneLimit the HLS stream playback duration, rounded to the nearest HLS segment
hls-playlist-reload-attempts
int3Max number of HLS playlist reload attempts before giving up
hls-playlist-reload-time
str | float"default"Override the HLS playlist reload time, either in seconds (
float) or as astrkeyword:segment: duration of the last segmentlive-edge: sum of segment durations of thehls-live-edgevalue minus onedefault: the playlist's target duration
hls-segment-queue-threshold
float3Factor of the playlist's targetduration which sets the threshold for stopping early on missing segments
hls-segment-stream-data
boolFalseStream data of HLS segment downloads to the output instead of waiting for the full response
hls-segment-ignore-names
List[str][]List of HLS segment names without file endings which should get filtered out
hls-segment-key-uri
str | NoneNoneOverride the address of the encrypted HLS stream's key, with support for the following string template variables:
{url},{scheme},{netloc},{path},{query}hls-audio-select
List[str][]Select a specific audio source or sources when multiple audio sources are available, by language code or name, or
"*"(asterisk)dash-manifest-reload-attempts
int3Max number of DASH manifest reload attempts before giving up
ffmpeg-ffmpeg
str | NoneNoneOverride for the
ffmpeg/ffmpeg.exebinary path, which by default gets looked up via thePATHenv varffmpeg-no-validation
boolFalseDisable FFmpeg validation and version logging
ffmpeg-verbose
boolFalseAppend FFmpeg's stderr stream to the Python's stderr stream
ffmpeg-verbose-path
str | NoneNoneWrite FFmpeg's stderr stream to the filesystem at the specified path
ffmpeg-loglevel
str | NoneNoneSet FFmpeg's
-loglevelvalueffmpeg-fout
str | NoneNoneSet the output format of muxed streams, e.g.
"matroska"ffmpeg-video-transcode
str | NoneNoneThe codec to use if transcoding video when muxing streams, e.g.
"h264"ffmpeg-audio-transcode
str | NoneNoneThe codec to use if transcoding video when muxing streams, e.g.
"aac"ffmpeg-copyts
boolFalseDon't shift input stream timestamps when muxing streams
ffmpeg-start-at-zero
boolFalseWhen
ffmpeg-copytsisTrue, shift timestamps to zerowebbrowser
boolTrueEnable or disable support for Streamlink's webbrowser API
webbrowser-executable
str | NoneNonePath to the web browser's executable
webbrowser-timeout
float20.0The maximum amount of time which the webbrowser can take to launch and execute
webbrowser-cdp-host
str | NoneNoneCustom host for the Chrome Devtools Protocol (CDP) interface
webbrowser-cdp-port
int | NoneNoneCustom port for the Chrome Devtools Protocol (CDP) interface
webbrowser-cdp-timeout
float2.0The maximum amount of time for waiting on a single CDP command response
webbrowser-headless
boolFalseWhether to launch the webbrowser in headless mode or not
- Parameters:
session (Streamlink)
- get(key)¶
Get the stored value of a specific key
- Parameters:
key (str)
- Return type:
Any
- set(key, value)¶
Set the value for a specific key
- Parameters:
key (str)
value (Any)
- Return type:
None
- class streamlink.session.plugins.StreamlinkPlugins(builtin=True, lazy=True)¶
Bases:
objectStreamlink's session-plugins implementation. This class is responsible for loading plugins and resolving them from URLs.
See the
Streamlink.pluginsattribute.Unless disabled by the user, Streamlink will try to load built-in plugins lazily, when accessing them for the first time while resolving input URLs. This is done by reading and interpreting serialized data of each plugin's
pluginmatcherandpluginargumentdata from a pre-built plugins JSON file which is included in Streamlink's wheel packages.Plugins which are sideloaded, either from specific user directories or custom input directories, always have a higher priority than built-in plugins.
- Parameters:
builtin (bool)
lazy (bool)
- __getitem__(item)¶
Access a loaded plugin class by name
- Parameters:
item (str)
- Return type:
type[Plugin]
- __setitem__(key, value)¶
Add/override a plugin class by name
- Parameters:
key (str)
value (type[Plugin])
- Return type:
None
- __delitem__(key)¶
Remove a loaded plugin by name
- Parameters:
key (str)
- Return type:
None
- __contains__(item)¶
Check if a plugin is loaded
- Parameters:
item (str)
- Return type:
bool
- get_names()¶
Get a list of the names of all available plugins
- Return type:
list[str]
- load_builtin()¶
Load Streamlink's built-in plugins
- Return type:
bool
- load_path(path)¶
Load plugins from a custom directory
- Parameters:
path (str | Path)
- Return type:
bool
- clear()¶
Remove all loaded plugins from the session
- iter_arguments()¶
Iterate through all plugins and their
Arguments- Return type:
Iterator[tuple[str, Arguments]]
- iter_matchers()¶
Iterate through all plugins and their
Matchers- Return type:
Iterator[tuple[str, Matchers]]