diff --git a/plexpy/activity_pinger.py b/plexpy/activity_pinger.py index 8ce2490f..1b99cf05 100644 --- a/plexpy/activity_pinger.py +++ b/plexpy/activity_pinger.py @@ -126,8 +126,8 @@ def check_active_sessions(ws_request=False): # Check if the user has reached the offset in the media we defined as the "watched" percent # Don't trigger if state is buffer as some clients push the progress to the end when # buffering on start. - if session['progress'] and session['duration'] and session['state'] != 'buffering': - if helpers.get_percent(session['progress'], + if session['view_offset'] and session['duration'] and session['state'] != 'buffering': + if helpers.get_percent(session['view_offset'], session['duration']) > plexpy.CONFIG.NOTIFY_WATCHED_PERCENT: # Push any notifications - # Push it on it's own thread so we don't hold up our db actions diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index 6fa10a9a..8ba72e23 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -830,14 +830,17 @@ class DataFactory(object): 'FROM sessions ' 'WHERE session_key = ?', args=[session_key]) - paused_counter = 0 + paused_counter = None for session in result: if session['last_paused']: paused_offset = int(time.time()) - int(session['last_paused']) paused_counter = int(session['paused_counter']) + int(paused_offset) values = {'state': 'playing', - 'last_paused': timestamp, - 'paused_counter': paused_counter} + 'last_paused': timestamp + } + if paused_counter: + values['paused_counter'] = paused_counter + keys = {'session_key': session_key} monitor_db.upsert('sessions', values, keys) \ No newline at end of file