Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / kill_stream_now.py
Last active February 16, 2017 12:47
Pulls active transcode streams from Plex and asks if you want to kill the stream.
'''
Kill kill_transcode function from https://gist.github.com/Hellowlol/ee47b6534410b1880e19
'''
import requests
import sys
import json
import platform
@blacktwin
blacktwin / kill_trans_pause.py
Last active September 29, 2017 17:10
Kills Plex transcode stream if paused. Set in PlexPy to be triggered when a user pauses or run manually.
'''
kill_transcode 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: kill_trans_pause.py
'''
@blacktwin
blacktwin / stream_limiter.py
Last active January 13, 2017 05:07
Limit user concurrent streams by unsharing libraries when concurrent stream count reaches limit. Restore sharing of libraries when concurrent stream is below limit.
"""
Share functions from https://gist.github.com/JonnyWong16/f8139216e2748cb367558070c1448636
Once user stream count hits LIMIT they are unshared from libraries.
Once user stream count is below LIMIT their shares are restored.
Unsharing does not pause or stop the user's stream.
After unsharing user can pause but not skip ahead or skip back.
Restrictions remain if unshared to shared while playing.
Effected user will need to refresh browser/app or restart app to reconnect.
User watch record stop when unshare is executed.
@blacktwin
blacktwin / notify_user_favorites.py
Last active March 23, 2017 19:25
Notify users of recently added episode to show that they have watched at least LIMIT times via email.
"""
Notify users of recently added episode to show that they have watched at least LIMIT times via email.
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
Adding to PlexPy
@blacktwin
blacktwin / I_have_haiku.txt
Last active January 17, 2017 16:15
With random words from each line from MLK's "I have a dream." speech, try to create a haiku. Lines were separated by periods. Lines 37, 39, 59, 61, 63 do not have enough words/syllable combinations so are skipped but printed.
I am happy to join with you today in what will go down in history as the greatest demonstration for freedom in the history of our nation.
Five score years ago, a great American, in whose symbolic shadow we stand today, signed the Emancipation Proclamation.
This momentous decree came as a great beacon light of hope to millions of Negro slaves who had been seared in the flames of withering injustice.
It came as a joyous daybreak to end the long night of their captivity.
But one hundred years later, the Negro still is not free.
One hundred years later, the life of the Negro is still sadly crippled by the manacles of segregation and the chains of discrimination.
One hundred years later, the Negro lives on a lonely island of poverty in the midst of a vast ocean of material prosperity.
One hundred years later, the Negro is still languishing in the corners of American society and finds himself an exile in his own land.
So we have come here today to dramatize a shameful condition.
In a sense we have come to our natio
@blacktwin
blacktwin / example_great_ani.py
Created January 18, 2017 03:47
Animating drawgreatcircle
import matplotlib
matplotlib.use("Agg")
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import matplotlib.animation as ani
import numpy as np
fig = plt.figure(figsize=(12, 7))
@blacktwin
blacktwin / sql_clear.py
Created January 19, 2017 20:04
Use with stream_limiter_ban_email.py to clear watch history of banned users.
"""
Use with stream_limiter_ban_email.py to clear watch history of banned users.
api_sql must be manually enabled in the config file.
"""
import requests
import sys