mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
Check concurrent streams from the server instead of database
This commit is contained in:
parent
41f91956b8
commit
c37e934f42
1 changed files with 12 additions and 4 deletions
|
@ -16,6 +16,7 @@
|
|||
|
||||
import arrow
|
||||
import bleach
|
||||
from collections import Counter
|
||||
from itertools import groupby
|
||||
import json
|
||||
from operator import itemgetter
|
||||
|
@ -145,10 +146,17 @@ def notify_conditions(notify_action=None, stream_data=None, timeline_data=None):
|
|||
return False
|
||||
|
||||
if notify_action == 'on_concurrent':
|
||||
ap = activity_processor.ActivityProcessor()
|
||||
user_sessions = ap.get_sessions(user_id=stream_data['user_id'],
|
||||
ip_address=plexpy.CONFIG.NOTIFY_CONCURRENT_BY_IP)
|
||||
return len(user_sessions) >= plexpy.CONFIG.NOTIFY_CONCURRENT_THRESHOLD
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
result = pms_connect.get_current_activity()
|
||||
|
||||
user_sessions = []
|
||||
if result:
|
||||
user_sessions = [s for s in result['sessions'] if s['user_id'] == stream_data['user_id']]
|
||||
|
||||
if plexpy.CONFIG.NOTIFY_CONCURRENT_BY_IP:
|
||||
return len(Counter(s['ip_address'] for s in user_sessions)) >= plexpy.CONFIG.NOTIFY_CONCURRENT_THRESHOLD
|
||||
else:
|
||||
return len(user_sessions) >= plexpy.CONFIG.NOTIFY_CONCURRENT_THRESHOLD
|
||||
|
||||
elif notify_action == 'on_newdevice':
|
||||
data_factory = datafactory.DataFactory()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue