Session#
- class streamlink.session.Streamlink(options=None)#
Bases:
objectThe 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.Sessionsubclass. Used for any kind of HTTP request made by plugin and stream implementations.
- options: Options#
Session options, which is a subclass of
Optionswith 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 | NoneNoneInstance of
UserInputRequesterto collect input from the user at runtimelocale
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
hls-segment-attempts (deprecated)
int3See
stream-segment-attemptshls-segment-threads (deprecated)
int3See
stream-segment-threadshls-segment-timeout (deprecated)
float10.00See
stream-segment-timeouthls-timeout (deprecated)
float60.00See
stream-timeoutdash-segment-attempts (deprecated)
int3See
stream-segment-attemptsdash-segment-threads (deprecated)
int3See
stream-segment-threadsdash-segment-timeout (deprecated)
float10.00See
stream-segment-timeoutdash-timeout (deprecated)
float60.00See
stream-timeouthttp-stream-timeout (deprecated)
float60.00See
stream-timeoutffmpeg-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-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
boolTrueWhether 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 (Optional[Options]) -- 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 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