2018-06-18 20:22:40 +00:00
# README
2018-04-13 01:06:13 +00:00
2018-06-18 20:22:40 +00:00
Killing streams is a Plex Pass only feature. So these scripts will **only** work for Plex Pass users.
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
## `kill_stream.py` examples:
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
### Kill transcodes
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Triggers: Playback Start
Conditions: \[ `Transcode Decision` | `is` | `transcode` \]
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop stream --username {username} --sessionId {session_id} --killMessage 'Transcoding streams are not allowed.'
2018-06-18 20:22:40 +00:00
```
2018-06-18 19:09:05 +00:00
2018-06-18 20:30:41 +00:00
### Kill non-local streams paused for a long time
_The default values will kill anything paused for over 20 minutes, checking every 30 seconds._
Script Timeout: 0 _**Important!**_
Triggers: Playback Paused
Conditions: \[ `Stream Local` | `is not` | `1` \]
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop paused --sessionId {session_id} --killMessage 'Your stream was paused for over 20 minutes and has been automatically stopped for you.'
2018-06-18 20:30:41 +00:00
```
### Kill streams paused for a custom time
_This is an example of customizing the paused stream monitoring to check every 15 seconds, and kill any stream paused for over 5 minutes._
Script Timeout: 0 _**Important!**_
Triggers: Playback Paused
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop paused --interval 15 --limit 300 --sessionId {session_id} --killMessage 'Your stream was paused for over 5 minutes and has been automatically stopped for you.'
2018-06-18 20:30:41 +00:00
```
2018-06-18 20:22:40 +00:00
### Kill paused transcodes
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Triggers: Playback Paused
Conditions: \[ `Transcode Decision` | `is` | `transcode` \]
2018-06-18 19:09:05 +00:00
2018-06-18 20:22:40 +00:00
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop stream --username {username} --sessionId {session_id} --killMessage 'Paused streams are automatically stopped.'
2018-06-18 20:22:40 +00:00
```
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
### Limit User stream count, kill last stream
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Triggers: Playback Start
Conditions: \[ `User Streams` | `is greater than` | `3` \]
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop stream --username {username} --sessionId {session_id} --killMessage 'You are only allowed 3 streams.'
2018-06-18 20:22:40 +00:00
```
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
### IP Whitelist
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Triggers: Playback Start
Conditions: \[ `IP Address` | `is not` | `192.168.0.100 or 192.168.0.101` \]
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop stream --username {username} --sessionId {session_id} --killMessage '{ip_address} is not allowed to access {server_name}.'
2018-06-18 20:22:40 +00:00
```
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
### Kill by platform
2018-06-18 19:09:05 +00:00
2018-06-18 20:22:40 +00:00
Triggers: Playback Start
Conditions: \[ `Platform` | `is` | `Roku or Android` \]
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop stream --username {username} --sessionId {session_id} --killMessage '{platform} is not allowed on {server_name}.'
2018-06-18 20:22:40 +00:00
```
2018-06-18 19:09:05 +00:00
2018-06-18 20:22:40 +00:00
### Kill transcode by library
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Triggers: Playback Start
Conditions:
* \[ `Transcode Decision` | `is` | `transcode` \]
* \[ `Library Name` | `is` | `4K Movies` \]
2018-06-18 19:09:05 +00:00
2018-06-18 20:22:40 +00:00
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop stream --username {username} --sessionId {session_id} --killMessage 'Transcoding streams are not allowed from the 4K Movies library.'
2018-06-18 20:22:40 +00:00
```
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
### Kill transcode by original resolution
2018-06-18 19:09:05 +00:00
2018-06-18 20:22:40 +00:00
Triggers: Playback Start
Conditions:
* \[ `Transcode Decision` | `is` | `transcode` \]
* \[ `Video Resolution` | `is` | `1080 or 720` \]
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop stream --username {username} --sessionId {session_id} --killMessage 'Transcoding streams are not allowed for {stream_video_resolution}p streams.'
2018-06-18 20:22:40 +00:00
```
2018-06-18 19:09:05 +00:00
2018-06-18 20:22:40 +00:00
### Kill transcode by bitrate
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Triggers: Playback Start
Conditions:
* \[ `Transcode Decision` | `is` | `transcode` \]
* \[ `Bitrate` | `is greater than` | `4000` \]
2018-06-18 19:09:05 +00:00
2018-06-18 20:22:40 +00:00
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop stream --username {username} --sessionId {session_id} --killMessage 'Transcoding streams are not allowed from over 4 Mbps (Yours: {stream_bitrate}).'
2018-06-18 20:22:40 +00:00
```
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
### Kill by hours of the day
2018-06-18 19:09:05 +00:00
2018-06-18 20:30:41 +00:00
_Kills any streams during 9 AM to 10 AM._
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Triggers: Playback Start
Conditions: \[ `Timestamp` | `begins with` | `09 or 10` \]
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop stream --username {username} --sessionId {session_id} --killMessage '{server_name} is unavailable between 9 and 10 AM.'
2018-06-18 20:22:40 +00:00
```
2018-06-18 19:09:05 +00:00
2018-06-18 20:22:40 +00:00
### Kill non local streams
2018-06-15 12:32:28 +00:00
2018-06-18 20:22:40 +00:00
Triggers: Playback Start
Conditions: \[ `Stream Local` | `is not` | `1` \]
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop stream --username {username} --sessionId {session_id} --killMessage '{server_name} only allows local streams.'
2018-06-18 20:22:40 +00:00
```
2018-06-18 19:09:05 +00:00
2018-06-18 20:22:40 +00:00
### Kill transcodes and send a notification to agent 1
Triggers: Playback Start
Conditions: \[ `Transcode Decision` | `is` | `transcode` \]
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop stream --username {username} --sessionId {session_id} --notify 1 --killMessage 'Transcoding streams are not allowed.'
2018-06-18 20:22:40 +00:00
```
### Kill transcodes using the default message
Triggers: Playback Start
Conditions: \[ `Transcode Decision` | `is` | `transcode` \]
Arguments:
```
--jbop stream --username {username} --sessionId {session_id}
```
### Kill all of a user's streams with notification
Triggers: Playback Start
Conditions: \[ `Username` | `is` | `Bob` \]
Arguments:
```
2018-06-27 21:40:32 +00:00
--jbop allStreams --userId {user_id} --notify 1 --killMessage 'Hey Bob, we need to talk!'
2018-06-18 20:22:40 +00:00
```
2018-09-09 00:33:17 +00:00
### Rich Notifications (Discord or Slack)
The following can be added to any of the above examples.
2018-09-26 13:09:16 +00:00
**How it Works:**
Tautulli > Script Agent > Script > Tautulli > Webhook Agent > Discord/Slack
1. Tautulli's script agent is executed
1. Script executes
1. The script sends the json data to the webhook agent
1. Webhook agent passes the information to Discord/Slack
2018-09-09 00:33:17 +00:00
**Limitations:**
* Due to [size ](https://api.slack.com/docs/message-attachments#thumb_url ) limitations by slack. A thumbnail may not appear with every notification when using `--posterUrl {poster_url}` .
* `allStreams` will not have poster images in the notifications.
**Required:**
`--notify notifierID --richMessage discord`
or
`--richMessage slack`
2018-09-26 13:09:16 +00:00
**_Note: The notifierID must be a Webhook in Tautulli_**
2018-09-09 00:33:17 +00:00
**Optional:**
2018-09-26 13:09:16 +00:00
```log
2018-09-09 00:33:17 +00:00
--serverName {server_name} --plexUrl {plex_url} --posterUrl {poster_url} --richColor '#E5A00D'
```
2018-09-26 13:09:16 +00:00
**Webhook Setup:**
1. Settings -> Notification Agents -> Add a new notification agent -> Webhook
1. For the **Webhook URL** enter your slack or discord webhook URL. </ br >
Some examples:
* Discord: [Intro to Webhooks ](https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks )
* Slack: [Incoming Webhooks ](https://api.slack.com/incoming-webhooks )
1. **Webhook Method** - `POST`
1. No triggers or any other configuration is needed. The script will pass the notifier the data to send to Discord/Slack.
2018-09-09 00:33:17 +00:00
< p >
< img width = "420" src = "https://i.imgur.com/9iQZsq4.png" >
< img width = "420" src = "https://i.imgur.com/VvivqCX.png" >
< / p >
2018-09-26 13:09:16 +00:00
### Debug
Add `--debug` to enable debug logging.