[Guide] killstream.py via Tautulli

This guide is no longer maintained.

killstream.py

killstream.py is a robust, small script Python script written by a few individuals who wanted to create tighter control around their Plex streaming. The primary purpose of killstream.py is to do just that, kill a stream. And using extensive logic within Tautulli, you can set up killstream.py to do quite a bit.

For this tutorial, I will walk you through setting up killstream.py to kill any stream trying to transcode a video greater than a certain bitrate and notify the streaming user. I have my conditions set to limit kill a stream if both the video resolution is greater than a threshold and the video is transcoding. You can adjust this number to whatever you wish and add other conditions.

Pre Requirements

Steps (in pictures)

Click add new notification.

In the script settings, under Script Folder specify the path to your killstream.py. The Script File is a dropdown that will populate with all valid files Tautulli can run for you from that directory.

Select your triggers. I went with Playback Start and Playback Resume. The Script will be run on these events.

Here is where we set our conditions. If you’ve not clicked Save, do so now. It will not close the popup. I save on each tab to prevent having to retype things…

I created two conditions. No need to fill out your Condition Logic if you’re doing something where you want all of the conditioned to be anded together; that’s the default behavior.

For each of the Trigger events you had selected earlier (in my case Playback Start and Playback Resume), pass in the killstream.py arguments you want. I’m going to kill the stream with the same message – see below:

--jbop stream --username {username} --sessionId {session_id} --killMessage 'Transcoding streams are not allowed for 4K content (Yours: {stream_bitrate}). Contact the Plex admin for help.'

{username} is your server username. The rest should be self explanatory. Modify to your liking.

Save & You’re done

You can learn more about the other options for killstream.py on there GitHub readme: JBOPS/killstream at master · blacktwin/JBOPS · GitHub

Pro Tip: You can set up a similar rule to prevent transcoding of Standard Definition (SD) if you want. This may be helpful if you want to encourage direct-play only setups or keep people in a bandwidth range you prefer. For example, I have another rule setup to prevent <4mbps as everyone who is on my system can do higher but sometimes they get a new client like a Fire Stick and forget to change the settings.

2 Likes