delete files, obsolete.

This commit is contained in:
Blacktwin 2018-06-12 10:06:45 -04:00
parent 714b87b6b3
commit e1d904727c
3 changed files with 0 additions and 185 deletions

View File

@ -1,48 +0,0 @@
"""
If user has 2* or more concurrent streams kill all user's streams
*Tautulli > Settings > Notification> User Concurrent Stream Threshold
The number of concurrent streams by a single user for Tautulli to trigger a notification. Minimum 2.
Tautulli > Settings > Notification Agents > Scripts > Bell icon:
[X] Notify on user concurrent streams
Tautulli > Settings > Notification Agents > Scripts > Gear icon:
Playback User Concurrent Streams: kill_more_than.py
Tautulli > Settings > Notifications > Script > Script Arguments
{user}
"""
import requests
import sys
from plexapi.server import PlexServer
## EDIT THESE SETTINGS ##
PLEX_TOKEN = 'xxxxx'
PLEX_URL = 'http://localhost:32400'
MESSAGE = 'Because....too many streams'
ignore_lst = ('')
## EDIT THESE SETTINGS ##
# 2nd stream information is passed
USERNAME = sys.argv[1]
if USERNAME in ignore_lst:
print(u"{} ignored.".format(USERNAME))
exit()
sess = requests.Session()
sess.verify = False
plex = PlexServer(PLEX_URL, PLEX_TOKEN, session=sess)
def kill_session(user):
for session in plex.sessions():
# Check for users stream
if session.usernames[0] == user:
print('Killing all of {user}\'s streams. Too many streams'.format(user=user))
session.stop(reason=MESSAGE)
kill_session(USERNAME)

View File

@ -1,66 +0,0 @@
"""
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.
*Tautulli > Settings > Notification> User Concurrent Stream Threshold
The number of concurrent streams by a single user for Tautulli to trigger a notification. Minimum 2.
Tautulli > Settings > Notification Agents > Scripts > Bell icon:
[X] Notify on user concurrent streams
Tautulli > Settings > Notification Agents > Scripts > Gear icon:
Playback User Concurrent Streams: kill_more_than.py
Tautulli > Settings > Notifications > Script > Script Arguments
{username} {ip_address} {session_key}
"""
import requests
import sys
from plexapi.server import PlexServer
## EDIT THESE SETTINGS ##
PLEX_TOKEN = 'xxxxx'
PLEX_URL = 'http://localhost:32400'
MESSAGE = 'Because....too many streams'
ignore_lst = ('')
## EDIT THESE SETTINGS ##
# 2nd stream information is passed
USERNAME = sys.argv[1]
ADDRESS = sys.argv[2]
SESSION_KEY = int(sys.argv[3])
if USERNAME in ignore_lst:
print(u"{} ignored.".format(USERNAME))
exit()
sess = requests.Session()
sess.verify = False
plex = PlexServer(PLEX_URL, PLEX_TOKEN, session=sess)
def kill_session(user, ip_address, session_key):
user_sessions = []
userip_sessions = []
for session in plex.sessions():
username = session.usernames[0]
address = session.players[0].address
if username == user:
user_sessions.append((session))
if username == user and address == ip_address:
userip_sessions.append((session))
if len(user_sessions) >= 2 > len(userip_sessions):
for session in user_sessions:
if session_key == session.sessionKey:
title = (session.grandparentTitle + ' - ' if session.type == 'episode' else '') + session.title
print(u"Killing {}'s second stream of {} for {}".format(user, title, MESSAGE))
session.stop(reason=MESSAGE)
else:
print(u"Not killing {}'s second stream. Same IP.".format(user))
kill_session(USERNAME, ADDRESS, SESSION_KEY)

View File

@ -1,71 +0,0 @@
"""
Kill Plex paused video transcoding streams and receive notification.
Tautulli > Settings > Notification Agents > Scripts > Bell icon:
[X] Notify on playback pause
Tautulli > Settings > Notification Agents > Scripts > Gear icon:
Playback Pause: kill_trans_pause.py
"""
import sys
import requests
from plexapi.server import PlexServer
## EDIT THESE SETTINGS ##
PLEX_URL = 'http://localhost:32400'
PLEX_TOKEN = 'xxxxx'
TAUTULLI_APIKEY = 'xxxxx' # Your Tautulli API key
TAUTULLI_URL = 'http://localhost:8181/' # Your Tautulli URL
KILL_MESSAGE = 'This stream has ended due to being paused and transcoding.'
USER_IGNORE = ('') # ('Username','User2')
SUBJECT_TEXT = "Killed Paused Transcoded Stream."
BODY_TEXT = "Killed {user}'s paused transcoded stream of {title}."
NOTIFIER_ID = 14 # Notification agent ID for Tautulli
# Find Notification agent ID here:
# Tautulli Settings -> NOTIFICATION AGENTS -> :bell: Agent (NotifierID - {Description)
##/EDIT THESE SETTINGS ##
sess = requests.Session()
sess.verify = False
plex = PlexServer(PLEX_URL, PLEX_TOKEN, session=sess)
def send_notification(subject_text, body_text):
# Send the notification through Tautulli
payload = {'apikey': TAUTULLI_APIKEY,
'cmd': 'notify',
'notifier_id': NOTIFIER_ID,
'subject': subject_text,
'body': body_text}
try:
r = requests.post(TAUTULLI_URL.rstrip('/') + '/api/v2', params=payload)
response = r.json()
if response['response']['result'] == 'success':
sys.stdout.write("Successfully sent Tautulli notification.")
else:
raise Exception(response['response']['message'])
except Exception as e:
sys.stderr.write("Tautulli API 'notify' request failed: {0}.".format(e))
return None
for session in plex.sessions():
username = session.usernames[0]
state = session.players[0].state
video_decision = session.transcodeSessions[0].videoDecision
title = (session.grandparentTitle + ' - ' if session.type == 'episode' else '') + session.title
if video_decision == 'transcode' and state == 'paused' and username not in USER_IGNORE:
sys.stdout.write("Killing {user}'s stream of {title}.".format(user=username, title=title))
session.stop(reason=KILL_MESSAGE)
send_notification(SUBJECT_TEXT, BODY_TEXT.format(user=username, title=title))