Skip to content

Commit 254bbba

Browse files
committed
Working on windows
1 parent 8f8255a commit 254bbba

File tree

6 files changed

+43
-70
lines changed

6 files changed

+43
-70
lines changed

addon.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<addon id="script.simkl"
33
name="Simkl TV Tracker Dev"
4-
version="0.1.1"
4+
version="0.2.1"
55
provider-name="David Davó / Simkl">
66
<requires>
77
<import addon="xbmc.python" version="2.6"/>

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v0.2.1 (2017-1-1)
2+
- Scrobble working fine on windows
3+
14
v0.1.1 (2016-12-23)
25
- Initial version
36
- Added notification bubble at scrobble

resources/lib/engine.py

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,39 @@ def synclibrary(self):
1919
### UPLOAD ###
2020
#DISABLED UNTIL WORKING FINE
2121
pass
22-
'''
23-
kodilibrary = xbmc.executeJSONRPC(json.dumps({
24-
"jsonrpc": "2.0",
25-
"method": "VideoLibrary.GetMovies",
26-
"params": {
27-
"limits": {
28-
"start": 0,
29-
"end": 1000
30-
},
31-
"properties": [
32-
"playcount",
33-
"imdbnumber",
34-
"file",
35-
"lastplayed"
36-
],
37-
"sort": {
38-
"order": "ascending",
39-
"method": "label",
40-
"ignorearticle": True
41-
}
42-
},
43-
"id": "libMovies"
44-
}))
45-
xbmc.log("Simkl: Ret: {}".format(kodilibrary))
46-
kodilibrary = json.loads(kodilibrary)
22+
# kodilibrary = xbmc.executeJSONRPC(json.dumps({
23+
# "jsonrpc": "2.0",
24+
# "method": "VideoLibrary.GetMovies",
25+
# "params": {
26+
# "limits": {
27+
# "start": 0,
28+
# "end": 1000
29+
# },
30+
# "properties": [
31+
# "playcount",
32+
# "imdbnumber",
33+
# "file",
34+
# "lastplayed"
35+
# ],
36+
# "sort": {
37+
# "order": "ascending",
38+
# "method": "label",
39+
# "ignorearticle": True
40+
# }
41+
# },
42+
# "id": "libMovies"
43+
# }))
44+
# xbmc.log("Simkl: Ret: {}".format(kodilibrary))
45+
# kodilibrary = json.loads(kodilibrary)
4746

48-
if kodilibrary["result"]["limits"]["total"] > 0:
49-
for movie in kodilibrary["result"]["movies"]:
50-
#Dont do that, upload all at once
47+
# if kodilibrary["result"]["limits"]["total"] > 0:
48+
# for movie in kodilibrary["result"]["movies"]:
49+
# #Dont do that, upload all at once
5150

52-
if movie["playcount"] > 0:
53-
imdb = movie["imdbnumber"]
54-
date = movie["lastplayed"]
55-
self.api.watched(imdb, "movie", date)
56-
'''
51+
# if movie["playcount"] > 0:
52+
# imdb = movie["imdbnumber"]
53+
# date = movie["lastplayed"]
54+
# self.api.watched(imdb, "movie", date)
5755

5856
class Player(xbmc.Player):
5957
def __init__(self):
@@ -102,8 +100,9 @@ def onPlayBackStopped(self):
102100
percentage = 100 * self.getTime() / self.getTotalTime()
103101
pctconfig = int(self.addon.getSetting("scr-pct"))
104102

105-
if percentage > pctconfig:
103+
if 99 > percentage > pctconfig:
106104
bubble = __addon__.getSetting("bubble")
105+
xbmc.log("Percentage: {}, pctconfig {}".format(percentage, pctconfig))
107106

108107
xbmc.log("Simkl: Ready to scrobble {}".format(movie.getTitle()))
109108
if imdb == "":

resources/lib/interface.py

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def notify(txt="Test"):
2222
#xmlfile = ""
2323
#script = __addon__.getAddonInfo("path").decode("utf-8")
2424
class loginDialog(xbmcgui.WindowXMLDialog):
25-
def __init__(self, xmlFilename, scriptPath, pin, url, check_login, log,
25+
def __init__(self, xmlFilename, scriptPath, pin, url, check_login, log,
2626
exp=900, inter=5, api=None):
2727
self.pin = pin
2828
self.url = url
@@ -64,41 +64,11 @@ def onInit(self):
6464
t.start()
6565

6666
def onControl(self, controlID):
67-
xbmc.log("Simkl: oncontrol {}".format(controlID))
67+
pass
6868
def onFocus(self, controlID):
6969
pass
7070

7171
def onClick(self, controlID):
7272
xbmc.log("Simkl: onclick {}".format(controlID))
7373
if controlID == CANCEL_BUTTON:
74-
self.canceled = True
75-
76-
'''
77-
class loginDialog:
78-
def __init__(self, url, pin, check_login, log, exp=900, inter=5, api=None):
79-
#TODO: If user is loged in, show a confirmation dialog
80-
API = api
81-
self.dialog = xbmcgui.DialogProgress()
82-
self.dialog.create(getstr(32021),
83-
getstr(32022).format(url), "PIN: {}".format(pin))
84-
waiting = True
85-
cnt = 0
86-
while waiting:
87-
pct = min(max(1, int( round( cnt*100 / exp, 0))), 99)
88-
self.dialog.update(pct, line3=getstr(32023).format(
89-
str(cnt).zfill(3), exp))
90-
91-
if cnt % (inter+1) == 0 and cnt>1:
92-
if check_login(pin,log):
93-
dialognot = xbmcgui.Dialog()
94-
xbmc.log(str(API.USERSETTINGS))
95-
dialognot.notification("Simkl", "Hello {}".format(
96-
API.USERSETTINGS["user"]["name"]))
97-
waiting = False
98-
#Now check the user has done what it has to be done
99-
time.sleep(1)
100-
cnt += 1
101-
if self.dialog.iscanceled() or cnt >= exp:
102-
waiting = False
103-
#raise Not logged in
104-
'''
74+
self.canceled = True

resources/lib/simklapi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ def is_locked(self, fname):
130130
def watched(self, filename, mediatype, duration, date=time.strftime('%Y-%m-%d %H:%M:%S')): #OR IDMB, member: only works with movies
131131
if self.is_user_logged() and not self.is_locked(filename):
132132
try:
133+
filename = filename.replace("\\", "/")
133134
con = httplib.HTTPSConnection("api.simkl.com")
134-
mediadict = {"movie": "movies", "episode":"episodes"}
135+
mediadict = {"movie": "movies", "episode":"episodes", "show":"show"}
135136

136137
if filename[:2] == "tt":
137138
toappend = {"ids":{"imdb":filename}, "watched_at":date}
@@ -143,8 +144,8 @@ def watched(self, filename, mediatype, duration, date=time.strftime('%Y-%m-%d %H
143144
xbmc.log("Simkl: Query: {}".format(values))
144145
con.request("GET", "/search/file/", body=values, headers=headers)
145146
r1 = con.getresponse().read().decode("utf-8")
147+
xbmc.log("Simkl: Response: {}".format(r1))
146148
r = json.loads(r1)
147-
xbmc.log("Simkl: Response: {}".format(r))
148149
if r == []:
149150
xbmc.log("Simkl: Couldn't scrobble: Null Response")
150151
return 0

script.simkl.zip

1.08 MB
Binary file not shown.

0 commit comments

Comments
 (0)