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,9 +125,10 @@ 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():
|
||||
logger.debug(u"Tautulli ActivityHandler :: Session %s paused." % str(self.get_session_key()))
|
||||
if not still_paused:
|
||||
logger.debug(u"Tautulli ActivityHandler :: Session %s paused." % str(self.get_session_key()))
|
||||
|
||||
# Set the session last_paused timestamp
|
||||
ap = activity_processor.ActivityProcessor()
|
||||
|
@ -142,7 +143,8 @@ class ActivityHandler(object):
|
|||
# Retrieve the session data from our temp table
|
||||
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
||||
|
||||
plexpy.NOTIFY_QUEUE.put({'stream_data': db_session, 'notify_action': 'on_pause'})
|
||||
if not still_paused:
|
||||
plexpy.NOTIFY_QUEUE.put({'stream_data': db_session, 'notify_action': 'on_pause'})
|
||||
|
||||
def on_resume(self):
|
||||
if self.is_valid_session():
|
||||
|
@ -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
|
||||
|
|
|
@ -446,7 +446,7 @@ class ActivityProcessor(object):
|
|||
if state:
|
||||
values['state'] = state
|
||||
|
||||
for k,v in kwargs.iteritems():
|
||||
for k, v in kwargs.iteritems():
|
||||
values[k] = v
|
||||
|
||||
keys = {'session_key': session_key}
|
||||
|
@ -460,7 +460,7 @@ class ActivityProcessor(object):
|
|||
if str(session_key).isdigit():
|
||||
self.db.action('DELETE FROM sessions WHERE session_key = ?', [session_key])
|
||||
|
||||
def set_session_last_paused(self, session_key=None, timestamp=None):
|
||||
def set_session_last_paused(self, session_key=None, timestamp=None ):
|
||||
if str(session_key).isdigit():
|
||||
result = self.db.select('SELECT last_paused, paused_counter '
|
||||
'FROM sessions '
|
||||
|
@ -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