Skip to content

Instantly share code, notes, and snippets.

@blacktwin
blacktwin / notify_on_added.py
Last active February 22, 2017 14:17
Send an Email notification when a specific show is added to Plex. Add shows to list that you want notifications for.
"""
PlexPy > Settings > Notification Agents > Scripts > Bell icon:
[X] Notify on Recently Added
PlexPy > Settings > Notification Agents > Scripts > Gear icon:
Recently Added: notify_on_added.py
PlexPy > Settings > Notifications > Script > Script Arguments:
-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}
You can add more arguments if you want more details in the email body
@blacktwin
blacktwin / notify_newip.py
Last active October 27, 2016 02:15
If a new IP is found send notification via the Email Notification Agent. Email contains User's Avatar image, link to location, IP address, and User's Email address.
"""
Pulling together User IP information and Email.
"""
import argparse
import requests
import sys
## -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} -ip {ip_address} -us {user} -uid {user_id} -pf {platform} -pl {player} -da {datestamp} -ti {timestamp}
@blacktwin
blacktwin / notify_newip_short.py
Last active February 14, 2017 23:11
If IP address is new use Email Notification Agent.
# 1. Install the requests module for python.
# pip install requests
# 2. Add script arguments in PlexPy.
# {user} {user_id} {ip_address}
import requests
import sys
user = sys.argv[1]
user_id = sys.argv[2]
@blacktwin
blacktwin / ip_to_map.py
Last active November 9, 2016 20:54
Pull all user IP data from PlexPy and using get_geoip_lookup grab the city name. Use the city name to map location on map.
import requests
import sys
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
from geopy.geocoders import Nominatim
import math
## EDIT THESE SETTINGS ##
PLEXPY_APIKEY = 'XXXXXXXXX' # Your PlexPy API key
PLEXPY_URL = 'http://localhost:8181/' # Your PlexPy URL
@blacktwin
blacktwin / ips_to_map_global_lonlat_labels.py
Last active December 19, 2017 22:43
Pull all user IP data from PlexPy and using get_geoip_lookup grab the long, lat, city name, IP, username. Use the long and lat to map location on map on global. Legend includes City and Username. Duplicates are removed in legend. Legend can be dragged. Client location plot size is based on play count.
import requests
import sys
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import matplotlib as mpl
from collections import OrderedDict
import math
import numpy as np
## EDIT THESE SETTINGS ##
@blacktwin
blacktwin / ips_to_map_states_lonlat_labels.py
Last active December 19, 2017 22:42
Pull all user IP data from PlexPy and using get_geoip_lookup grab the long, lat, city name, IP, username. Use the long and lat to map location on map on USA. Legend includes City and Username. Duplicates are removed in legend. Legend can be dragged. Client location plot size is based on play count.
import requests
import sys
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import matplotlib as mpl
from collections import OrderedDict
import math
# Example: http://i.imgur.com/IXd0IVM.png
@blacktwin
blacktwin / rand_ip_hops.py
Last active December 11, 2016 16:49
Travel from random Class C IPs
import pygeoip
import matplotlib.pyplot as plt
import matplotlib as mpl
import random
import numpy as np
from mpl_toolkits.basemap import Basemap
from collections import OrderedDict
from geopy.geocoders import Nominatim
geolocator = Nominatim()
@blacktwin
blacktwin / check_play.py
Last active November 8, 2017 22:56
Check if user has play a file more than 3 times but has not finished watching. Hoping to catch play failures.
# 1. Install the requests module for python.
# pip install requests
# 2. Add script arguments in PlexPy.
# {user} {title}
# Add to Playback Resume
import requests
import sys
user = sys.argv[1]
@blacktwin
blacktwin / check_plex_log.py
Last active December 22, 2016 05:46
Checking plex logs for debug code WARN and 'Failed to obtain a streaming resource for transcode of key /library/metadata/"titleID"'.
'''
Run script by itself. Will look for WARN code followed by /library/metadata/ str in Plex logs.
This is find files that are corrupt or having playback issues.
I corrupted a file to test.
'''
import requests
import sys
## EDIT THESE SETTINGS ##
@blacktwin
blacktwin / drive_check.py
Last active December 23, 2016 13:28
Check if drive exists. If not then notify via PlexPy notifier agent
import psutil
import requests
import urllib
# Drive letter to check if exists.
drive = 'D:'
disk = psutil.disk_partitions()
PLEXPY_URL = 'http://localhost:8181/' # Your PlexPy URL