Skip to content

Instantly share code, notes, and snippets.

@blacktwin
blacktwin / tracert_t.py
Last active January 3, 2017 17:57
Prints tracert output to console then projects map of hop locations with connecting lines. Random IP if set to blank with Country code restriction.
'''
Need GeoLiteCity.dat
https://dev.maxmind.com/geoip/legacy/geolite/
Place in root of tracert_t.py
'''
import pygeoip
import matplotlib.pyplot as plt
import matplotlib as mpl
@blacktwin
blacktwin / rand_hop_paths_movie.py
Last active May 7, 2017 04:25
Animate path from random IP location to random IP location. Speed up video in post processing.
'''
Need GeoLiteCity.dat
https://dev.maxmind.com/geoip/legacy/geolite/
Need FFMEPG
https://ffmpeg.zeranoe.com/builds/
Both in root of rand_hop_paths_movie.py
'''
@blacktwin
blacktwin / notify_user_newip.py
Last active January 23, 2017 13:57
Notify user that their account has been accessed by a new IP. IP is cleared to make sure notification is sent again.
"""
Pulling together User IP information and Email.
Enable the API under Settings > Access Control and remember your API key.
Shutdown PlexPy and open your config.ini file in a text editor.
Set api_sql = 1 in the config file.
Restart PlexPy.
Place in Playback Start
"""
import argparse
import requests
@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
@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 / 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 / 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 / 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 / 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 / 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