Skip to content

Commit d1aaedb

Browse files
committed
Fix #3
1 parent 254bbba commit d1aaedb

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

resources/lib/engine.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,12 @@ def getMediaType():
7171
return None
7272

7373
def onPlayBackStarted(self):
74-
self.onPlayBackStopped()
75-
def onPlayBackSeek(self, *args):
7674
#self.onPlayBackStopped()
7775
pass
76+
def onPlayBackSeek(self, *args):
77+
self.onPlayBackStopped()
7878
def onPlayBackResumed(self):
79-
#self.onPlayBackStopped()
80-
pass
79+
self.onPlayBackStopped()
8180
def onPlayBackEnded(self):
8281
xbmc.log("Simkl: ONPLAYBACKENDED")
8382
self.onPlayBackStopped()
@@ -119,3 +118,5 @@ def onPlayBackStopped(self):
119118

120119
except RuntimeError:
121120
pass
121+
except ZeroDivisionError:
122+
self.onPlayBackStopped()

resources/lib/simklapi.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,22 @@ def is_user_logged(self):
112112

113113
### SCROBBLING OR CHECKIN
114114
def lock(self, fname, duration):
115-
d = self.scrobbled_dict
116-
d[fname] = time.time() + (100 - int(__addon__.getSetting("scr-pct"))) / 100 * duration
117-
xbmc.log("Simkl: Locking {}".format(d))
115+
xbmc.log("Duration: %s" %duration)
116+
exp = self.scrobbled_dict
117+
exp[fname] = int(time.time() + (105 - float(__addon__.getSetting("scr-pct"))) / 100 * duration)
118+
xbmc.log("Simkl: Locking {}".format(exp))
118119

119120
def is_locked(self, fname):
120-
d = self.scrobbled_dict
121-
if not (fname in d.keys()): return 0
122-
if d[fname] < time.time():
123-
xbmc.log("Simkl: Can't scrobble, file locked")
124-
xbmc.log(str(d))
121+
exp = self.scrobbled_dict
122+
if not (fname in exp.keys()): return 0
123+
xbmc.log("Time: {}, exp: {}, Dif: {}".format(int(time.time()), exp[fname], int(exp[fname]-time.time())))
124+
#When Dif reaches 0, scrobble.
125+
if time.time() < exp[fname]:
126+
xbmc.log("Simkl: Can't scrobble, file locked (alredy scrobbled)")
127+
xbmc.log(str(exp))
125128
return 1
126129
else:
127-
del d[fname]
130+
del exp[fname]
128131
return 0
129132

130133
def watched(self, filename, mediatype, duration, date=time.strftime('%Y-%m-%d %H:%M:%S')): #OR IDMB, member: only works with movies

script.simkl.zip

-17 MB
Binary file not shown.

tozip.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#Creates a zip file compatible with Kodi
33

44
mkdir script.simkl
5-
rsync -rv --progress ./ ./script.simkl --exclude-from .gitignore --exclude tozip.sh
6-
75
rm script.simkl.zip
8-
zip -rx@.gitignore script.simkl.zip script.simkl/*
9-
rm -Rf script.simkl
6+
7+
rsync -rv --progress ./ ./script.simkl --exclude-from .gitignore --exclude tozip.sh
8+
zip -rx@.gitignore script.simkl.zip script.simkl/* -x script.simkl/script.simkl/
9+
rm -Rf script.simkl

0 commit comments

Comments
 (0)