Skip to content

Commit e08f3d1

Browse files
committed
Pre v1
1 parent f424d5e commit e08f3d1

File tree

12 files changed

+99
-40
lines changed

12 files changed

+99
-40
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,5 @@ ENV/
9090

9191
# Rope project settings
9292
.ropeprojectKodi.rar
93+
94+
script\.simkl\.zip

addon.xml

Lines changed: 4 additions & 4 deletions
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"
4-
version="0.2.4"
4+
version="1.0.0"
55
provider-name="David Davó / Simkl">
66
<requires>
77
<import addon="xbmc.python" version="2.6"/>
@@ -14,13 +14,13 @@
1414
<disclaimer lang="en_gb">Currently under development</disclaimer>
1515
<description lang="en_gb">Automatically set Movies and TV Shows\Anime as watched on Simkl.com. Simkl knows what you're watching, tells you episodes you've missed, and connects you to what your friends are into.</description>
1616
<platform>all</platform>
17-
<license>Not Licensed yet</license>
17+
<license>GPLv3</license>
1818
<email>[email protected]</email>
19-
<source>https://github.com/SIMKL/Kodi</source>
19+
<source>https://github.com/SIMKL/script.simkl</source>
2020
<assets>
2121
<icon>resources/icon.png</icon>
2222
<fanart>resources/fanart.png</fanart>
2323
</assets>
24-
<language>en</language>
24+
<language>en es</language>
2525
</extension>
2626
</addon>

changelog.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1+
v 1.0.0 [17/01/25]:
2+
- Ready for submiting to the Kodi repositories
3+
4+
v 0.2.5 [17/01/22]:
5+
- When Scrobbled using filename, get data from Simkl. Fix #11
6+
17
v 0.2.4 [17/01/15]:
2-
- Fixed #7
3-
- Fixed #8
4-
- Fixed #9
5-
- Fixed #5
8+
- Fixed #7. Rescrobbling duplicate.
9+
- Fixed a settings button (#8)
10+
- Fixed SSL Timed out (#9)
11+
- Enhanced login (#5)
612

713
v 0.2.3 [17/01/04]:
8-
- Fixed #4
14+
- Fixed bubbles (#4)
915

1016
v 0.2.2 [17/01/03]:
11-
- Fixed #3
17+
- Fixed Reescrobbling (#3)
1218

1319
v 0.2.1 [17/01/01]:
1420
- Working w/ Kodi for Windows

resources/data/compdate.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2017-01-26 17:04:00+01:00

resources/language/English/strings.po

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,30 @@ msgctxt "#32028"
7474
msgid "Scrobbling {}"
7575
msgstr ""
7676

77+
msgctxt "#32029"
78+
msgid "Error at scrobbling. Retrying ({})"
79+
msgstr ""
80+
81+
msgctxt "#32030"
82+
msgid "Login successful, {}"
83+
msgstr ""
84+
85+
msgctxt "#32031"
86+
msgid "Couldn't log in"
87+
msgstr ""
88+
89+
msgctxt "#32032"
90+
msgid "You are alredy logged in as {}"
91+
msgstr ""
92+
93+
msgctxt "#32033"
94+
msgid "Continue"
95+
msgstr ""
96+
97+
msgctxt "#32034"
98+
msgid "Cancel"
99+
msgstr ""
100+
77101
#msgctxt "#"
78102
#msgid ""
79103
#msgstr ""

resources/language/Spanish/strings.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ msgid "Simkl login"
4949
msgstr "Inicio de sesión en Simkl"
5050

5151
msgctxt "#32022"
52-
msgid "Enter to the following URL: {}"
53-
msgstr "Entra a la siguiente URL: {}"
52+
msgid "Please visit {} on \nyour device and enter this code"
53+
msgstr "Por favor visita {}\n en tu dispositivo e introduce el código"
5454

5555
msgctxt "#32023"
5656
msgid "Remaining time: {}/{}"
@@ -70,8 +70,8 @@ msgctxt "#32027"
7070
msgid "You don't have internet"
7171
msgstr "No tienes conexión a internet"
7272

73-
msgctxt "#32028"
74-
msgid "Scrobbling {}"
73+
msgctxt "#32028"
74+
msgid "Scrobbling {}"
7575
msgstr "Scrobbling {}"
7676

7777
#msgctxt "#"

resources/lib/engine.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,19 @@ def onPlayBackStopped(self):
8484
'''Gets the info needed to pass to the api'''
8585
try:
8686
movie = self.getVideoInfoTag()
87-
imdb = movie.getIMDBNumber().strip(" ")
88-
fname = self.getPlayingFile()
8987
thing = xbmc.executeJSONRPC(json.dumps({"jsonrpc": "2.0", "method": "Player.GetItem",
90-
"params": { "properties": [ "showtitle", "title", "season", "episode" ]
88+
"params": { "properties": [ "showtitle", "title", "season", "episode", "file", "imdbnumber", "genre" ]
9189
, "playerid": 1 }, "id": "VideoGetItem"}))
9290
xbmc.log("Simkl: Full: {}".format(thing))
9391
item = json.loads(thing)["result"]["item"]
92+
#imdb = movie.getIMDBNumber().strip(" ")
93+
#fname = self.getPlayingFile()
94+
imdb = item["imdbnumber"]
95+
fname = item["file"]
9496
media = item["type"]
9597
xbmc.log("Simkl: IMDb: {}".format(imdb))
96-
xbmc.log("Simkl: Genre: " + movie.getGenre())
98+
xbmc.log("Simkl: Genre: {}".format(item["genre"]))
9799
xbmc.log("Simkl: MediaType: " + str(media))
98-
#Scrobble from filename only for testing purposes or error of other methods
99100

100101
percentage = 100 * self.getTime() / self.getTotalTime()
101102
pctconfig = int(self.addon.getSetting("scr-pct"))
@@ -107,19 +108,34 @@ def onPlayBackStopped(self):
107108

108109
xbmc.log("Simkl: Ready to scrobble {}".format(movie.getTitle()))
109110
if imdb == "":
111+
#if True:
110112
xbmc.log("Simkl: No imdb - Fname: {}".format(fname))
111113
r = self.api.watched(fname, media, self.getTotalTime())
112114
else:
113115
xbmc.log("Simkl: IMDB: " + str(imdb))
114116
r = self.api.watched(imdb, media, self.getTotalTime())
115117

116118
if bubble=="true" and r:
119+
if item["label"] in item["file"]:
120+
#if True: #For testing purposes
121+
xbmc.log("Simkl: Label and file are the same")
122+
lstw = self.api.lastwatched
123+
if lstw["type"] == "episode":
124+
item["showtitle"] = lstw["show"]["title"]
125+
item["season"] = lstw["episode"]["season"]
126+
item["episode"] = lstw["episode"]["episode"]
127+
elif lstw["type"] == "movie":
128+
item["title"] = "".join([lstw["movie"]["title"], " (", str(lstw["movie"]["year"]), ")"])
129+
media = lstw["type"]
130+
117131
txt = item["label"]
118132
title = ""
119-
if media == "movie": txt = item["title"]
133+
if media == "movie":
134+
txt = item["title"]
120135
elif media == "episode":
121136
txt = item["showtitle"]
122137
title = "- S{:02}E{:02}".format(item["season"], item["episode"])
138+
xbmc.log("Simkl: " + "; ".join([media, txt, title]))
123139
interface.notify(getstr(32028).format(title), title=txt)
124140
r = 0
125141

resources/lib/interface.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def notify(txt="Test", title="Simkl", icon=__icon__):
2525
#xmlfile = ""
2626
#script = __addon__.getAddonInfo("path").decode("utf-8")
2727
def login(logged):
28-
"Change the things that need to be changed. E.g: The settings dialog"
28+
"""Change the things that need to be changed. E.g: The settings dialog"""
2929
__addon__.setSetting("loginbool", str(bool(1)).lower())
3030

3131
class loginDialog(xbmcgui.WindowXMLDialog):
@@ -51,15 +51,15 @@ def threaded(self):
5151
if self.check_login(self.pin, self.log):
5252

5353
xbmc.log(str(self.api.USERSETTINGS))
54-
notify("Hello {}".format(self.api.USERSETTINGS["user"]["name"]))
54+
notify(getstr(32030).format(self.api.USERSETTINGS["user"]["name"]))
5555
self.waiting = False
5656
#Now check that the user has done what it has to be done
5757

5858
cnt += 1
5959
time.sleep(1)
6060
if self.canceled or cnt >= self.exp:
6161
self.waiting = False
62-
notify("Couldn't log in")
62+
notify(getstr(32031))
6363

6464
xbmc.log("Simkl: Stop waiting")
6565
self.close()
@@ -70,18 +70,22 @@ def onInit(self):
7070
instruction.setLabel(
7171
getstr(32022).format("[COLOR ffffbf00]" + self.url + "[/COLOR]"))
7272
self.getControl(PIN_LABEL).setLabel(self.pin)
73+
xbmc.log("Simkl: Visible: {}".format(self.getProperty("visible")))
7374

74-
#t = threading.Thread(target=self.threaded)
75+
t = threading.Thread(target=self.threaded)
76+
t.start()
7577

7678
if API.is_user_logged(): #If user is alredy logged in
7779
dialog = xbmcgui.Dialog()
7880
username = API.USERSETTINGS["user"]["name"]
79-
ret = dialog.yesno("Simkl LogIn Warning", "You are alredy logged in as {}".format(username),
80-
nolabel="Cancel", yeslabel="Continue", autoclose=30000)
81+
ret = dialog.yesno("Simkl LogIn Warning", getstr(32032).format(username),
82+
nolabel=getstr(32034), yeslabel=getstr(32033), autoclose=30000)
8183
#xbmc.log("Ret: {}".format(ret))
8284
xbmc.log("Simkl:ret: {}".format(ret))
83-
if ret == 1: pass #t.start()
84-
elif ret == 0: self.onClick(CANCEL_BUTTON)
85+
if ret == 1: pass
86+
elif ret == 0:
87+
self.onClick(CANCEL_BUTTON)
88+
return
8589

8690
def onControl(self, controlID):
8791
pass
@@ -90,6 +94,7 @@ def onFocus(self, controlID):
9094

9195
def onAction(self, action):
9296
if action == ACTION_PREVIOUS_MENU or action == ACTION_BACK:
97+
self.canceled = True
9398
self.close()
9499

95100
def onClick(self, controlID):

resources/lib/simklapi.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
def getstr(strid): return interface.getstr(strid)
1818

1919
REDIRECT_URI = "http://simkl.com"
20-
USERFILE = xbmc.translatePath("special://profile/simkl_key")
20+
USERFILE = xbmc.translatePath(__addon__.getAddonInfo("profile")).decode("utf-8") + "simkl_key"
21+
xbmc.translatePath("special://profile/simkl_key")
22+
2123
if not os.path.exists(USERFILE):
2224
with open(USERFILE, "w") as f:
2325
f.write("")
2426
else:
2527
with open(USERFILE, "r") as f:
26-
print(xbmc.log("Simkl Userfile " + str(f.read())))
28+
xbmc.log("Simkl Userfile " + str(f.read()))
2729

2830
with open(os.path.dirname(os.path.realpath(__file__)).strip("lib") + "data/apikey") as f:
2931
d = json.loads(f.read())
@@ -119,6 +121,7 @@ def lock(self, fname, duration):
119121
exp = self.scrobbled_dict
120122
exp[fname] = int(time.time() + (105 - float(__addon__.getSetting("scr-pct"))) / 100 * duration)
121123
xbmc.log("Simkl: Locking {}".format(exp))
124+
self.scrobbled_dict = {fname:exp[fname]} #So there is always only one entry on the dict
122125

123126
def is_locked(self, fname):
124127
exp = self.scrobbled_dict
@@ -149,9 +152,10 @@ def watched(self, filename, mediatype, duration, date=time.strftime('%Y-%m-%d %H
149152
values = json.dumps(values)
150153
xbmc.log("Simkl: Query: {}".format(values))
151154
con.request("GET", "/search/file/", body=values, headers=headers)
152-
r1 = con.getresponse().read().decode("utf-8")
155+
r1 = con.getresponse().read()#.decode("utf-8")
153156
xbmc.log("Simkl: Response: {}".format(r1))
154-
r = json.loads(r1)
157+
r = json.loads(str(r1))
158+
self.lastwatched = r
155159
if r == []:
156160
xbmc.log("Simkl: Couldn't scrobble: Null Response")
157161
return 0
@@ -178,10 +182,10 @@ def watched(self, filename, mediatype, duration, date=time.strftime('%Y-%m-%d %H
178182
xbmc.log("Simkl: {}".format("ERROR: httplib.BadStatusLine"))
179183
except SSLError: #Fix #8
180184
xbmc.log("Simkl: ERROR: SSLError, retrying?")
181-
if cnt == 0: interface.notify("Error at scrobbling. Try number %s" % cnt+1)
185+
if cnt == 0: interface.notify(getstr(32029).format(cnt+1))
182186
if cnt <= 3:
183187
self.watched(filename, mediatype, duration, date=date, cnt=cnt+1)
184-
else: interface.notify("I give up :(")
188+
else: interface.notify("SSLError")
185189

186190
else:
187191
xbmc.log("Simkl: Can't scrobble. User not logged in or file locked")
@@ -191,6 +195,4 @@ def watched(self, filename, mediatype, duration, date=time.strftime('%Y-%m-%d %H
191195
if __name__ == "__main__":
192196
if sys.argv[1] == "login":
193197
xbmc.log("Logging in", level=xbmc.LOGDEBUG)
194-
api.login()
195-
if sys.argv[1] == "test":
196-
api.scrobble_from_filename("South Park S01E02")
198+
api.login()

resources/settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<setting label="Auto-scrobble" type="bool" id="autoscrobble" default="true" enable="false"/>
1515
<setting label="32006" type="slider" id="scr-pct" default="70" range="0,100" option="percent" enable="gt(-1,-2)" />
1616
<setting label="32007" type="slider" id="sct-w-pct" default="10" range="0,100" option="
17-
percent"/>
17+
percent" visible="false"/>
1818
<setting label="32008" type="bool" id="bubble" default="true" enable="true"/>
1919
</category>
2020
</settings>

0 commit comments

Comments
 (0)