From e69b01e8258d4a82121bb1c2bf444ea92eb89563 Mon Sep 17 00:00:00 2001
From: angelblue05 <tamara.angel05@gmail.com>
Date: Thu, 11 Jan 2018 02:09:18 -0600
Subject: [PATCH] Fix clear playlist

---
 resources/lib/player.py    | 6 +++++-
 resources/lib/playutils.py | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/resources/lib/player.py b/resources/lib/player.py
index 9ff6d178..0dca7b63 100644
--- a/resources/lib/player.py
+++ b/resources/lib/player.py
@@ -496,7 +496,11 @@ class Player(xbmc.Player):
                 else:
                     playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
 
-                if playlist.getposition < 0:
+                if int(playlist.getposition()) < 0:
+                    ''' If playback is stopped within the first 30 seconds,
+                        Kodi doesn't consider this watched and playlist should not be cleared.
+                        When the end is reached, position is -1.
+                    '''
                     log.info("Clear playlist, end detected.")
                     playlist.clear()
 
diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py
index 40bf9bd5..f8968f08 100644
--- a/resources/lib/playutils.py
+++ b/resources/lib/playutils.py
@@ -4,6 +4,7 @@
 
 import collections
 import logging
+import os
 import urllib
 
 import xbmc