Skip to content

Instantly share code, notes, and snippets.

@blacktwin
blacktwin / delete_watched_TV.py
Created April 10, 2017 14:02
From a list of TV shows, check if users in a list has watched shows episodes. If all users in list have watched an episode of listed show, then delete episode
"""
From a list of TV shows, check if users in a list has watched shows episodes.
If all users in list have watched an episode of listed show, then delete episode.
"""
import requests
import sys
import os
@blacktwin
blacktwin / create_wait_kill_all.py
Last active June 11, 2018 16:43
Receive session_key from PlexPy when paused. Use session_id to create sub-script to wait for X time then check if still paused. If paused kill.
'''
fetch function from https://gist.github.com/Hellowlol/ee47b6534410b1880e19
PlexPy > Settings > Notification Agents > Scripts > Bell icon:
[X] Notify on pause
PlexPy > Settings > Notification Agents > Scripts > Gear icon:
Playback Pause: create_wait_kill_all.py
PlexPy > Settings > Notifications > Script > Script Arguments:
{session_key}
@blacktwin
blacktwin / notify_fav_tv_all_movie.py
Last active December 19, 2017 22:38
Notify users of recently added episode to show that they have watched at least LIMIT times via email. Also notify users of new movies.
"""
Notify users of recently added episode to show that they have watched at least LIMIT times via email.
Also notify users of new movies.
Block users with IGNORE_LST.
Arguments passed from PlexPy
-sn {show_name} -ena {episode_name} -ssn {season_num00} -enu {episode_num00} -srv {server_name} -med {media_type}
-pos {poster_url} -tt {title} -sum {summary} -lbn {library_name} -grk {grandparent_rating_key}
You can add more arguments if you want more details in the email body
@blacktwin
blacktwin / kill_outsider_stream.py
Last active January 2, 2020 19:29
Kill stream if user is outside of local network.
"""
Kill stream of user if they are accessing Plex from outside network
PlexPy > Settings > Notification Agents > Scripts > Bell icon:
[X] Notify on playback start
PlexPy > Settings > Notification Agents > Scripts > Gear icon:
Playback Start: kill_outsider_stream.py
PlexPy > Settings > Notifications > Script > Script Arguments
@blacktwin
blacktwin / removed_watched_movies.py
Last active July 3, 2020 09:01
Find Movies that have been watched by a list of users. If all users have watched movie then delete.
"""
Find Movies that have been watched by a list of users.
If all users have watched movie than delete.
Deletion is prompted
"""
import requests
import sys
import os
@blacktwin
blacktwin / kill_all_more_than.py
Last active July 22, 2018 20:05
If user has 2* or more concurrent streams kill all streams
"""
If user has 2* or more concurrent streams kill all user's streams
*PlexPy > Settings > Notification> User Concurrent Stream Threshold
The number of concurrent streams by a single user for PlexPy to trigger a notification. Minimum 2.
PlexPy > Settings > Notification Agents > Scripts > Bell icon:
[X] Notify on user concurrent streams
@blacktwin
blacktwin / kill_more_than.py
Last active July 15, 2023 19:05
If user has 2* or more concurrent streams and the IP of the 2nd stream differs from 1st kill 2nd. If 2nd stream IP is the same as 1st stream don't kill.
"""
If user has 2* or more concurrent streams and the IP of the 2nd stream differs from 1st kill 2nd.
If 2nd stream IP is the same as 1st stream don't kill.
*PlexPy > Settings > Notification> User Concurrent Stream Threshold
The number of concurrent streams by a single user for PlexPy to trigger a notification. Minimum 2.
PlexPy > Settings > Notification Agents > Scripts > Bell icon:
[X] Notify on user concurrent streams
@blacktwin
blacktwin / kill_session_bitrate.py
Last active September 10, 2017 12:00
Kill stream if bitrate is greater than 4 Mbps
"""
PlexPy Playback Start
"""
import requests
import platform
from uuid import getnode
import unicodedata
## EDIT THESE SETTINGS ##
@blacktwin
blacktwin / kill_plex_stream.py
Last active February 27, 2017 17:04
Kill any Plex stream for whatever reason you want.
import requests
import platform
from uuid import getnode
## EDIT THESE SETTINGS ##
PLEX_HOST = ''
PLEX_PORT = 32400
PLEX_SSL = '' # s or ''
PLEX_TOKEN = 'xxxxxx'
@blacktwin
blacktwin / aired_today_playlist.py
Created February 26, 2017 22:25
Create a Plex Playlist with what was aired on this today's month-day, sort by oldest first, using PlexAPI
"""
Create a Plex Playlist with what was aired on this today's month-day, sort by oldest first.
If Playlist from yesterday exists delete and create today's.
If today's Playlist exists exit.
"""
import operator, time
from plexapi.server import PlexServer
import requests