21 Custom Scripts
JonnyWong16 edited this page 2022-05-20 18:24:57 -07:00

How to Download Scripts from Github

Click on the Raw button on the script page to get the actual script file, then use File > Save As.. to save the script.

Do not use right click > Save As.. on the script link as this will save the HTML GitHub page instead of the script.

How to Set Up a Custom Script in Tautulli

  1. Go to Settings > Notification Agents > Add new notification agent > Script.

  2. Set a "Script Folder" and select a "Script File".

  3. Select the triggers that will be used to run the script. (e.g. Playback Start, Playback Stop).

  4. If you want to limit when the script runs, add custom conditions to the agent.

  5. Set the arguments that should be passed to the script.

    • Note: Do not fill in the Tautulli notification {parameters}.

  6. Save. Voilà, all done!

  7. If you are using the "Test Notifications" tab for the script, you must fill in all the Tautulli {parameters} with actual values.

    • For example script arguments:
      --jbop stream --username {username} --sessionId {session_id}
      
    • You must fill in the {username} and {session_id}:
      --jbop stream --username MyPlexUsername --sessionId a0elgoy822nso9tr3l0coh
      

Environment Variables

Tautulli will pass the following environment variables to the script.

Variable Description
PLEX_URL The URL used to connect to the Plex server (e.g. http://127.0.0.1:32400).
PLEX_TOKEN The admin's Plex token.
PLEX_USER_TOKEN The user's Plex token only available for notifications with a user context (i.e. Playback triggers).
TAUTULLI_URL The URL used to connect to the Tautulli server (e.g. http://127.0.0.1:8181).
TAUTULLI_PUBLIC_URL The Public Tautulli Domain only if set in the Tautulli settings.
TAUTULLI_APIKEY The Tautulli API key.

Windows Script Guide

Note: These instructions only apply if you are running a Python script.

How to Install Python

  1. Disable the Windows Python app execution aliases.

    1. Search for "Manage app execution aliases" in your Windows settings. (screenshot)
    2. Disable python.exe and python3.exe app execution aliases. (screenshot)
  2. Download the latest version of Python from python.org and run the installer.

  3. In the Python installation wizard check the option to "Add Python to PATH", then click on "Customize installation". (screenshot)

  4. Under the Advanced Options check the options "Install for all users" and "Add Python to environment variables". (screenshot)

  5. Finally, click on "Install".

  6. You can check if Python is installed properly by opening up the Windows command line and running the command python -V (note capital letter V) and it should tell you the version of Python installed. (screenshot)

How to Install Python Packages

  1. Check which Python packages your script requires. Some script authors will list the requirements at the top of the script (example), otherwise contact the script author. You can also just try running the script (see below) and see which ModuleNotFoundError you get which will tell you which packages are needed.

    • Example error message: ModuleNotFounderror: No module named 'plexapi' means you need to install the plexapi package.
  2. Install packages by opening up the command line and running the command:

    python -m pip install <package>
    
    • Example to install the plexapi package (screenshot):
      python -m pip install plexapi
      
    • Example to install the requests package (screenshot):
      python -m pip install requests
      

How to Run a Python Script Manually

Open up the command line and run the script you downloaded using Python with the following command:

python "<path to script file>" --additional arguments
  • Note: --additional arguments depends on the individual script.
  • Example:
    python "C:\Users\JohnDoe\Documents\Scripts\hide_episode_spoilers.py" --rating_key 69420 --blur 25
    

List of User Created Scripts

Visit the JBOPS GitHub Repository for more up-to-date scripts created by @Blacktwin.

Tautulli Scripts:

Description Language Author
Kill streams Python blacktwin
Throttle nzb client Python Hellowlol
Send an Email notification to users when a new episode to their "favorite" show have been added to Plex Python blacktwin
Send a Tautulli notification with the movie directors' IMDB page Python JonnyWong16
Send a random Chuck Norris joke when a movie starring Chuck Norris is played Python JonnyWong16
Send a Tautulli notification with geolocation data Python JonnyWong16
Get notified when Plex disk usage exceeds a certain threshold Python JonnyWong16
Delete Tautulli history older than "X" days Python JonnyWong16
Restart Plex bat Hellowlol
Plex Docker Container Restart with Rancher Bash JigSawFr
Tautulli - Quiet hours and smart batching for Pushbullet notifications Python JimboMonkey1234
Generate map from user geolocation data Python blacktwin
Get notified when new IP address accesses Plex Python blacktwin
Run a SSH command using Python Python JonnyWong16
Automatically add a label to recently added items Python JonnyWong16
Automatically mark a multi-episode file as watched in Plex Python JonnyWong16
Automatically change episode artwork in Plex to hide spoilers Python JonnyWong16
Updates all metadata in the Tautulli database after moving Plex libraries Python JonnyWong16
Send recently added through native iOS push (OneSignal) Python LuisNunezC
Notify Sonarr that a plexDVR recording has been added to the library Bash metaMMA
Notification script for Facebook Groups Python spuniun

Other Plex Scripts:

Description Language Author
Automatically share and unshare libraries for Plex users Python JonnyWong16
Execute a command when no Plex sessions are active Python JonnyWong16
Create a Plex collection from a text file list of rating keys Python JonnyWong16
Sync Plex playlists to shared users Python JonnyWong16
Removes ALL collections from ALL movies Python JonnyWong16
Saves artist.jpg to the Artist folder. Python JonnyWong16
Randomly create haiku based on Plex libraries content. Python Blacktwin
Create a Plex Playlist with what was aired today in history. Python Blacktwin
Pull Movie and TV Show poster images from Plex. Python Blacktwin
Download theme songs from Plex TV Shows. Python Blacktwin
Delete shows that a list of users have watched. Python Blacktwin
Delete movies that a list of users have watched. Python Blacktwin