Updated playcount check in KodiMonitor, if playcount was empty / null it would incorrectly mark it as watched.

While updating play state make sure offset never exceeds item duration.
This commit is contained in:
RickDB 2017-07-17 12:30:12 +02:00 committed by tomkat83
parent c173823e77
commit 643899ce49
2 changed files with 8 additions and 1 deletions

View file

@ -158,6 +158,12 @@ class Items(object):
# If the playback was stopped, check whether we need to increment the # If the playback was stopped, check whether we need to increment the
# playcount. PMS won't tell us the playcount via websockets # playcount. PMS won't tell us the playcount via websockets
if item['state'] in ('stopped', 'ended'): if item['state'] in ('stopped', 'ended'):
# If offset exceeds duration skip update
if item['viewOffset'] > item['duration']:
log.error("Error while updating play state, viewOffset exceeded duration")
return
complete = float(item['viewOffset']) / float(item['duration']) complete = float(item['viewOffset']) / float(item['duration'])
log.info('Item %s stopped with completion rate %s percent.' log.info('Item %s stopped with completion rate %s percent.'
'Mark item played at %s percent.' 'Mark item played at %s percent.'

View file

@ -92,6 +92,7 @@ class KodiMonitor(Monitor):
# Manually marking as watched/unwatched # Manually marking as watched/unwatched
playcount = data.get('playcount') playcount = data.get('playcount')
item = data.get('item') item = data.get('item')
try: try:
kodiid = item['id'] kodiid = item['id']
item_type = item['type'] item_type = item['type']
@ -114,7 +115,7 @@ class KodiMonitor(Monitor):
window('plex_skipWatched%s' % itemid, clear=True) window('plex_skipWatched%s' % itemid, clear=True)
else: else:
# notify the server # notify the server
if playcount != 0: if playcount > 0:
scrobble(itemid, 'watched') scrobble(itemid, 'watched')
else: else:
scrobble(itemid, 'unwatched') scrobble(itemid, 'unwatched')