mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 21:51:14 -07:00
Update paused time while still paused
This commit is contained in:
parent
4e3b95950f
commit
ca20eda606
2 changed files with 15 additions and 9 deletions
|
@ -125,8 +125,9 @@ class ActivityHandler(object):
|
|||
% (str(self.get_session_key()), str(self.get_rating_key())))
|
||||
ap.delete_session(session_key=self.get_session_key())
|
||||
|
||||
def on_pause(self):
|
||||
def on_pause(self, still_paused=False):
|
||||
if self.is_valid_session():
|
||||
if not still_paused:
|
||||
logger.debug(u"Tautulli ActivityHandler :: Session %s paused." % str(self.get_session_key()))
|
||||
|
||||
# Set the session last_paused timestamp
|
||||
|
@ -142,6 +143,7 @@ class ActivityHandler(object):
|
|||
# Retrieve the session data from our temp table
|
||||
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
||||
|
||||
if not still_paused:
|
||||
plexpy.NOTIFY_QUEUE.put({'stream_data': db_session, 'notify_action': 'on_pause'})
|
||||
|
||||
def on_resume(self):
|
||||
|
@ -242,6 +244,11 @@ class ActivityHandler(object):
|
|||
|
||||
elif this_state == 'buffering':
|
||||
self.on_buffer()
|
||||
|
||||
elif this_state == 'paused':
|
||||
# Update the session last_paused timestamp
|
||||
self.on_pause(still_paused=True)
|
||||
|
||||
# If a client doesn't register stop events (I'm looking at you PHT!) check if the ratingKey has changed
|
||||
else:
|
||||
# Manually stop and start
|
||||
|
|
|
@ -469,15 +469,14 @@ class ActivityProcessor(object):
|
|||
paused_counter = None
|
||||
for session in result:
|
||||
if session['last_paused']:
|
||||
paused_offset = int(time.time()) - int(session['last_paused'])
|
||||
paused_offset = timestamp - int(session['last_paused'])
|
||||
if session['paused_counter']:
|
||||
paused_counter = int(session['paused_counter']) + int(paused_offset)
|
||||
else:
|
||||
paused_counter = int(paused_offset)
|
||||
|
||||
values = {'state': 'playing',
|
||||
'last_paused': timestamp
|
||||
}
|
||||
values = {'last_paused': timestamp}
|
||||
|
||||
if paused_counter:
|
||||
values['paused_counter'] = paused_counter
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue