Session#

Bases: object

The Streamlink session is used to load and resolve plugins, and to store options used by plugins and stream implementations.

Parameters:

options (Options) -- Custom options

http: HTTPSession#

An instance of Streamlink's requests.Session subclass. Used for any kind of HTTP request made by plugin and stream implementations.

options: Options#

Session options, which is a subclass of Options with additional getter/setter mappings for special options.

set_option(key, value)#

Sets general options used by plugins and streams originating from this session object.

Parameters:
  • key (str) -- key of the option

  • value (Any) -- value to set the option to

Return type:

None

Available options:

key

type

default

description

user-input-requester

UserInputRequester | None

None

Instance of UserInputRequester to collect input from the user at runtime

locale

str

system locale

Locale setting, in the RFC 1766 format, e.g. en_US or es_ES

interface

str | None

None

Network interface address

ipv4

bool

False

Resolve address names to IPv4 only, overrides ipv6

ipv6

bool

False

Resolve address names to IPv6 only, overrides ipv4

http-proxy

str | None

None

Proxy address for all HTTP/HTTPS requests

https-proxy (deprecated)

str | None

None

Proxy address for all HTTP/HTTPS requests

http-cookies

dict[str, str] | str

{}

A dict or a semicolon ; delimited str of cookies to add to each HTTP/HTTPS request, e.g. foo=bar;baz=qux

http-headers

dict[str, str] | str

{}

A dict or a semicolon ; delimited str of headers to add to each HTTP/HTTPS request, e.g. foo=bar;baz=qux

http-query-params

dict[str, str] | str

{}

A dict or an ampersand & delimited str of query string parameters to add to each HTTP/HTTPS request, e.g. foo=bar&baz=qux

http-trust-env

bool

True

Trust HTTP settings set in the environment, such as environment variables (HTTP_PROXY, etc.) and ~/.netrc authentication

http-ssl-verify

bool

True

Verify TLS/SSL certificates

http-disable-dh

bool

False

Disable TLS/SSL Diffie-Hellman key exchange

http-ssl-cert

str | tuple | None

None

TLS/SSL certificate to use, can be either a .pem file (str) or a .crt/.key pair (tuple)

http-timeout

float

20.0

General timeout used by all HTTP/HTTPS requests, except the ones covered by other options

ringbuffer-size

int

16777216 (16 MiB)

The size of the internal ring buffer used by most stream types

mux-subtitles

bool

False

Make supported plugins mux available subtitles into the output stream

stream-segment-attempts

int

3

Number of segment download attempts in segmented streams

stream-segment-threads

int

1

The size of the thread pool used to download segments in parallel

stream-segment-timeout

float

10.0

Segment connect and read timeout

stream-timeout

float

60.0

Timeout for reading data from stream

hls-live-edge

int

3

Number of segments from the live position of the HLS stream to start reading

hls-live-restart

bool

False

Skip to the beginning of a live HLS stream, or as far back as possible

hls-start-offset

float

0.0

Number of seconds to skip from the beginning of the HLS stream, interpreted as a negative offset for livestreams

hls-duration

float | None

None

Limit the HLS stream playback duration, rounded to the nearest HLS segment

hls-playlist-reload-attempts

int

3

Max 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 a str keyword:

  • segment: duration of the last segment

  • live-edge: sum of segment durations of the hls-live-edge value minus one

  • default: the playlist's target duration

hls-segment-queue-threshold

float

3

Factor of the playlist's targetduration which sets the threshold for stopping early on missing segments

hls-segment-stream-data

bool

False

Stream 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 | None

None

Override 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

int

3

Max number of DASH manifest reload attempts before giving up

hls-segment-attempts (deprecated)

int

3

See stream-segment-attempts

hls-segment-threads (deprecated)

int

3

See stream-segment-threads

hls-segment-timeout (deprecated)

float

10.00

See stream-segment-timeout

hls-timeout (deprecated)

float

60.00

See stream-timeout

dash-segment-attempts (deprecated)

int

3

See stream-segment-attempts

dash-segment-threads (deprecated)

int

3

See stream-segment-threads

dash-segment-timeout (deprecated)

float

10.00

See stream-segment-timeout

dash-timeout (deprecated)

float

60.00

See stream-timeout

http-stream-timeout (deprecated)

float

60.00

See stream-timeout

ffmpeg-ffmpeg

str | None

None

Override for the ffmpeg/ffmpeg.exe binary path, which by default gets looked up via the PATH env var

ffmpeg-no-validation

bool

False

Disable FFmpeg validation and version logging

ffmpeg-verbose

bool

False

Append FFmpeg's stderr stream to the Python's stderr stream

ffmpeg-verbose-path

str | None

None

Write FFmpeg's stderr stream to the filesystem at the specified path

ffmpeg-fout

str | None

None

Set the output format of muxed streams, e.g. "matroska"

ffmpeg-video-transcode

str | None

None

The codec to use if transcoding video when muxing streams, e.g. "h264"

ffmpeg-audio-transcode

str | None

None

The codec to use if transcoding video when muxing streams, e.g. "aac"

ffmpeg-copyts

bool

False

Don't shift input stream timestamps when muxing streams

ffmpeg-start-at-zero

bool

False

When ffmpeg-copyts is True, shift timestamps to zero

webbrowser

bool

True

Enable or disable support for Streamlink's webbrowser API

webbrowser-executable

str | None

None

Path to the web browser's executable

webbrowser-timeout

float

20.0

The maximum amount of time which the webbrowser can take to launch and execute

webbrowser-cdp-host

str | None

None

Custom host for the Chrome Devtools Protocol (CDP) interface

webbrowser-cdp-port

int | None

None

Custom port for the Chrome Devtools Protocol (CDP) interface

webbrowser-cdp-timeout

float

2.0

The maximum amount of time for waiting on a single CDP command response

webbrowser-headless

bool

True

Whether to launch the webbrowser in headless mode or not

get_option(key)#

Returns the current value of the specified option.

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

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

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 dict of stream names and Stream instances

get_plugins()#

Returns the loaded plugins for the session.

load_plugins(path)#

Attempt to load plugins from the path specified.

Parameters:

path (str) -- full path to a directory where to look for plugins

Returns:

success

Return type:

bool