This script is designed to automate the management of a Plex media server, qBittorrent client, and an Unraid server. It checks the number of active streams on the Plex server and adjusts the speed mode of the qBittorrent client accordingly. It also provides functionality to pause or resume a parity check operation on the Unraid server as well as pausing the mover and resuming when there are no streams (only if the mover was interrupted).
Before using this script, make sure you have the following:
- 'Parity Check Tuning' plugin by Dave Walker (itimpi)
- Tautulli docker container by JonnyWong16
- The required Python packages installed in the Tautulli container:
requests
,re
,qbittorrentapi
,paramiko
python-dotenv
. (create a user script that runs at the start of the array with the following:docker exec tautulli pip install requests qbittorrent-api paramiko python-dotenv
)
- Clone or download the script to your script folder as
/appdata/Tautulli/scripts/plex-qbit-unraid.py
- Clone or download the .env file to your script folder as
/appdata/Tautulli/scripts/.env
- Replace the values (REPLACEME) in the .env file with login details for your set up.
- Make sure you have
Use increments for manual Parity Check
andUse increments for scheduled Parity Check
set to YES in the 'Parity Check Tuning' plugin. You can also setUse increments for automatic Parity Check
to yes, but it's not recommenced. - Set up a new Script in Tautulli by going to
Settings
>Notification Agents
>Add a new notification agent
>Script
. On theConfiguration
tab. Add your scripts folder/config/scripts
and your script file './plex-qbit-unraid.py
. Then on theTriggers
tab, addPlayback Start
andPlayback Stop
as your only triggers and save. - Adjust the limits of the qBittorrent by going to
Tools
>Speed
then setting theAlternate Rate Limits
to your desired speed and save. The speed is up to you and what your setup can handle. .
After that, you should be good to go!
Now, every time something is started or stopped in Plex, the script will check if anyone is watching and slowdown qBittorrent/pause a parity check or speedup qBittorrent, resume parity check, and resume the mover if it was interrupted. This will only happen when there are 0 people steaming. You can check the Tautulli logs to see what the script is doing.