fix for title and transcode sessions
This commit is contained in:
parent
27db3a6eaa
commit
591c299af6
@ -40,9 +40,11 @@ def kill_session(sess_key, message):
|
|||||||
# Check for users stream
|
# Check for users stream
|
||||||
username = session.usernames[0]
|
username = session.usernames[0]
|
||||||
if session.sessionKey == sess_key:
|
if session.sessionKey == sess_key:
|
||||||
title = (session.grandparentTitle + ' - ' if session.type == 'episode' else '') + session.title
|
title = unicode(session.grandparentTitle + ' - ' if session.type == 'episode' else '') + session.title
|
||||||
print('{user} is watching {title} and they might be asleep.'.format(user=username, title=title))
|
title = unicodedata.normalize('NFKD', title).encode('ascii', 'ignore').translate(None, "'")
|
||||||
session.stop(reason=message)
|
session.stop(reason=message)
|
||||||
|
print('Terminated {user}\'s stream of {title} to prioritize admin stream.'.format(user=username,
|
||||||
|
title=title))
|
||||||
|
|
||||||
|
|
||||||
def add_to_dictlist(d, key, val):
|
def add_to_dictlist(d, key, val):
|
||||||
@ -56,13 +58,14 @@ def main():
|
|||||||
user_dict = {}
|
user_dict = {}
|
||||||
|
|
||||||
for session in plex.sessions():
|
for session in plex.sessions():
|
||||||
|
if session.transcodeSessions:
|
||||||
trans_dec = session.transcodeSessions[0].videoDecision
|
trans_dec = session.transcodeSessions[0].videoDecision
|
||||||
username = session.usernames[0]
|
username = session.usernames[0]
|
||||||
if trans_dec == 'transcode' and username not in ADMIN_USER:
|
if trans_dec == 'transcode' and username not in ADMIN_USER:
|
||||||
sess_key = session.sessionKey
|
sess_key = session.sessionKey
|
||||||
percent_comp = int((float(session.viewOffset) / float(session.duration)) * 100)
|
percent_comp = int((float(session.viewOffset) / float(session.duration)) * 100)
|
||||||
time_to_comp = int(int(session.duration) - int(session.viewOffset)) / 1000 / 60
|
time_to_comp = int(int(session.duration) - int(session.viewOffset)) / 1000 / 60
|
||||||
title = (session.grandparentTitle + ' - ' if session.type == 'episode' else '') + session.title
|
title = unicode(session.grandparentTitle + ' - ' if session.type == 'episode' else '') + session.title
|
||||||
title = unicodedata.normalize('NFKD', title).encode('ascii', 'ignore').translate(None, "'")
|
title = unicodedata.normalize('NFKD', title).encode('ascii', 'ignore').translate(None, "'")
|
||||||
add_to_dictlist(user_dict, username, [sess_key, percent_comp, title, username, time_to_comp])
|
add_to_dictlist(user_dict, username, [sess_key, percent_comp, title, username, time_to_comp])
|
||||||
|
|
||||||
@ -71,6 +74,7 @@ def main():
|
|||||||
if len(value) is not 1}
|
if len(value) is not 1}
|
||||||
|
|
||||||
# Find who to kill and who will be finishing first.
|
# Find who to kill and who will be finishing first.
|
||||||
|
if filtered_dict:
|
||||||
for users in filtered_dict.values():
|
for users in filtered_dict.values():
|
||||||
to_kill = min(users, key=itemgetter(1))
|
to_kill = min(users, key=itemgetter(1))
|
||||||
to_finish = max(users, key=itemgetter(1))
|
to_finish = max(users, key=itemgetter(1))
|
||||||
|
Loading…
Reference in New Issue
Block a user