In Python script, how to make streamlink to write to a log file.>

616 Views Asked by At

Hi I have a python script that looks for a video stream, if the stream is found it will do something.

When streamlink does NOT find a stream it displays a message (this is standard functionality) "Could not get video info - ERROR: Video unavailable".

In the documentation it says you can write to a log file but I am at a loss... this is what I call

 streams = streamlink.streams (channel_stream)

How do I complete that statement to have streamlink to log to /var/stramlink.log

Thanks in advance. h

1

There are 1 best solutions below

3
On

From the documentation it looks like you can set log file settings on a streamlink session using an instance of the session:

subprocess-errorlog (bool) Log errors from subprocesses to a file located in the temp directory

subprocess-errorlog-path (str) Log errors from subprocesses to a specific file

ffmpeg-verbose (bool) Log stderr from ffmpeg to the console

ffmpeg-verbose-path (str) Specify the location of the ffmpeg stderr log file

These settings can be set something like:

streamlink.set_option('subprocess-errorlog', true)
streamlink.set_option('subprocess-errorlog-path', '/path/to/streamlink_error.log')
streamlink.set_option('ffmpeg-verbose', true)
streamlink.set_option('ffmpeg-verbose-path', '/path/to/ffmpeg_error.log')