From aa83776a8bcb5891aecd2a9a796ed6fdb2191478 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sat, 23 Sep 2017 18:40:30 +0200 Subject: [PATCH] Move MARK_PLAYED_AT to variables.py --- resources/lib/itemtypes.py | 5 ++--- resources/lib/player.py | 6 ++---- resources/lib/variables.py | 1 + 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 8c01114d..4347be0f 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -22,7 +22,6 @@ import state log = logging.getLogger("PLEX."+__name__) -MARK_PLAYED_AT = 0.90 ############################################################################### @@ -168,8 +167,8 @@ class Items(object): complete = float(item['viewOffset']) / float(item['duration']) log.info('Item %s stopped with completion rate %s percent.' 'Mark item played at %s percent.' - % (item['ratingKey'], str(complete), MARK_PLAYED_AT), 1) - if complete >= MARK_PLAYED_AT: + % (item['ratingKey'], str(complete), v.MARK_PLAYED_AT), 1) + if complete >= v.MARK_PLAYED_AT: log.info('Marking as completely watched in Kodi') try: item['viewCount'] += 1 diff --git a/resources/lib/player.py b/resources/lib/player.py index 63596d88..2672e275 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -347,11 +347,9 @@ class Player(xbmc.Player): except ZeroDivisionError: # Runtime is 0. percentComplete = 0 - - markPlayed = 0.90 log.info("Percent complete: %s Mark played at: %s" - % (percentComplete, markPlayed)) - if percentComplete >= markPlayed: + % (percentComplete, v.MARK_PLAYED_AT)) + if percentComplete >= v.MARK_PLAYED_AT: # Kodi seems to sometimes overwrite our playstate, so wait xbmc.sleep(500) # Tell Kodi that we've finished watching (Plex knows) diff --git a/resources/lib/variables.py b/resources/lib/variables.py index 95042299..856197d3 100644 --- a/resources/lib/variables.py +++ b/resources/lib/variables.py @@ -21,6 +21,7 @@ def tryDecode(string, encoding='utf-8'): string = string.decode() return string +MARK_PLAYED_AT = 0.9 _ADDON = Addon() ADDON_NAME = 'PlexKodiConnect'