Skip to content

Instantly share code, notes, and snippets.

@blacktwin
blacktwin / find_unwatched_notify.py
Last active December 11, 2018 03:23
Find what was added TFRAME ago and not watched and notify admin using PlexPy.
"""
Find what was added TFRAME ago and not watched and notify admin using PlexPy.
"""
import requests
import sys
import time
@blacktwin
blacktwin / find_unwatched.py
Last active December 11, 2018 03:40
Find what was added TFRAME ago and not watched using PlexPy.
"""
Find what was added TFRAME ago and not watched using PlexPy.
"""
import requests
import sys
import time
@blacktwin
blacktwin / stream_limiter_ban_email.py
Last active October 27, 2020 21:33
This is indented to restrict a user to the LIMIT amount of concurrent streams. User will be warned, punished, and banned completely if violations continue.
"""
Share functions from https://gist.github.com/JonnyWong16/f8139216e2748cb367558070c1448636
Once user stream count hits LIMIT they are unshared from libraries expect for banned library.
Once user stream count is below LIMIT and banned library video is watched their shares are restored.
Once violation count have been reached ban permanently.
Caveats:
Unsharing doesn't pause the stream.
After unsharing user can pause but not skip ahead or skip back.
@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
@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 / 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 / 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 / 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 / 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 / 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