Skip to content

Commit db4bd50

Browse files
committed
Notification bubble at scrobbling
1 parent 8e8aa0a commit db4bd50

File tree

13 files changed

+48
-18
lines changed

13 files changed

+48
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Kodi
22

33
## Installing
4-
1. Download the .zip [here](https://github.com/SIMKL/script.service.simkl/blob/master/script.service.simkl.zip)
4+
1. Download the .zip [here](https://github.com/SIMKL/script.service.simkl/blob/master/script.simkl.zip)
55
2. Open Kodi and go to Settings > Add-ons > Install from zip file, select the zip file
66
3. In Settings > Add-ons > My add-ons and search for Simkl TV Tracker. Click on it.
77
4. Click on Configure to configure the add-on (Login and scrobbler options)

addon.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.service.simkl"
2+
<addon id="script.simkl"
33
name="Simkl TV Tracker Dev"
4-
version="0.0.1"
4+
version="0.1.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
@@ -0,0 +1,3 @@
1+
v0.1.1 (2016-12-23)
2+
- Initial version
3+
- Added notification bubble at scrobble

icon.png

86.2 KB
Loading

resources/language/English/strings.po

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ msgid "Enter to the following URL: {}"
5353
msgstr ""
5454

5555
msgctxt "#32023"
56-
msgcid "Remaining time: {}/{}"
56+
msgid "Remaining time: {}/{}"
5757
msgstr ""
5858

5959
# Blahblahblah
@@ -70,6 +70,10 @@ msgctxt "#32027"
7070
msgid "You don't have internet"
7171
msgstr ""
7272

73+
msgctxt "#32028"
74+
msgid "Scrobbling {}"
75+
msgstr ""
76+
7377
#msgctxt "#"
7478
#msgid ""
7579
#msgstr ""

resources/language/Spanish/strings.po

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ msgid "Enter to the following URL: {}"
5353
msgstr "Entra a la siguiente URL: {}"
5454

5555
msgctxt "#32023"
56-
msgcid "Remaining time: {}/{}"
56+
msgid "Remaining time: {}/{}"
5757
msgstr "Tiempo restante: {}/{}"
5858

5959
# Blahblahblah
@@ -70,6 +70,10 @@ msgctxt "#32027"
7070
msgid "You don't have internet"
7171
msgstr "No tienes conexión a internet"
7272

73+
msgctxt "#32028"
74+
msgid "Scrobbling {}"
75+
msgstr "Scrobbling {}"
76+
7377
#msgctxt "#"
7478
#msgid ""
7579
#msgstr ""

resources/lib/engine.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import xbmc, xbmcaddon
55
import interface
66
import json
7+
__addon__ = interface.__addon__
8+
def getstr(id): return interface.getstr(id)
79

810
class Engine:
911
def __init__(self, api, player):
@@ -15,7 +17,9 @@ def __init__(self, api, player):
1517

1618
def synclibrary(self):
1719
### UPLOAD ###
18-
20+
#DISABLED UNTIL WORKING FINE
21+
pass
22+
'''
1923
kodilibrary = xbmc.executeJSONRPC(json.dumps({
2024
"jsonrpc": "2.0",
2125
"method": "VideoLibrary.GetMovies",
@@ -41,6 +45,7 @@ def synclibrary(self):
4145
}))
4246
xbmc.log("Simkl: Ret: {}".format(kodilibrary))
4347
kodilibrary = json.loads(kodilibrary)
48+
4449
if kodilibrary["result"]["limits"]["total"] > 0:
4550
for movie in kodilibrary["result"]["movies"]:
4651
#Dont do that, upload all at once
@@ -49,6 +54,7 @@ def synclibrary(self):
4954
imdb = movie["imdbnumber"]
5055
date = movie["lastplayed"]
5156
self.api.watched(imdb, "movie", date)
57+
'''
5258

5359
class Player(xbmc.Player):
5460
def __init__(self):
@@ -82,10 +88,10 @@ def onPlayBackStopped(self):
8288
movie = self.getVideoInfoTag()
8389
imdb = movie.getIMDBNumber().strip(" ")
8490
fname = self.getPlayingFile()
85-
media = xbmc.executeJSONRPC(json.dumps({"jsonrpc": "2.0", "method": "Player.GetItem",
91+
thing = xbmc.executeJSONRPC(json.dumps({"jsonrpc": "2.0", "method": "Player.GetItem",
8692
"params": { "properties": [ "showtitle", "streamdetails","title"]
8793
, "playerid": 1 }, "id": "VideoGetItem"}))
88-
media = json.loads(media)["result"]["item"]["type"]
94+
media = json.loads(thing)["result"]["item"]["type"]
8995
xbmc.log("Simkl: IMDb: {}".format(imdb))
9096
xbmc.log("Simkl: Genre: " + movie.getGenre())
9197
xbmc.log("Simkl: MediaType: " + str(media))
@@ -95,13 +101,20 @@ def onPlayBackStopped(self):
95101
pctconfig = int(self.addon.getSetting("scr-pct"))
96102

97103
if percentage > pctconfig:
104+
bubble = __addon__.getSetting("bubble")
105+
98106
xbmc.log("Simkl: Ready to scrobble {}".format(movie.getTitle()))
99107
if imdb == "":
100108
xbmc.log("Simkl: No imdb - Fname: {}".format(fname))
101-
self.api.watched(fname, media)
109+
r = self.api.watched(fname, media) #r from response
102110
else:
103111
xbmc.log("Simkl: IMDB: " + str(imdb))
104-
self.api.watched(imdb, media)
112+
r = self.api.watched(imdb, media)
113+
114+
if bubble and r:
115+
xbmc.log("Simkl: Full: {}".format(thing))
116+
interface.notify(getstr(32028).format(
117+
json.loads(thing)["result"]["item"]["label"]))
105118

106119
except RuntimeError:
107120
pass

resources/lib/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import time
55
tmp = time.time()
66

7-
__addon__ = xbmcaddon.Addon("script.service.simkl")
7+
__addon__ = xbmcaddon.Addon("script.simkl")
88
__icon__ = __addon__.getAddonInfo("icon")
99
def getstr(id): return __addon__.getLocalizedString(id)
1010

resources/lib/simklapi.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import interface
1414
import httplib
1515

16+
__addon__ = interface.__addon__
1617
def getstr(id): return interface.getstr(id)
1718

1819
REDIRECT_URI = "http://simkl.com"
@@ -123,11 +124,16 @@ def watched(self, filename, mediatype, date=time.strftime('%Y-%m-%d %H:%M:%S')):
123124

124125
xbmc.log("Simkl: values {}".format(tosend))
125126
con.request("GET", "/sync/history/", body=tosend, headers=headers)
126-
xbmc.log("Simkl: {}".format(con.getresponse().read().decode("utf-8")))
127+
r = con.getresponse().read().decode("utf-8")
128+
xbmc.log("Simkl: {}".format(r))
129+
130+
return max(json.loads(r)["added"].values())
131+
127132
except httplib.BadStatusLine:
128133
xbmc.log("Simkl: {}".format("ERROR: httplib.BadStatusLine"))
129134
else:
130135
xbmc.log("Simkl: Can't scrobble. User not logged in")
136+
return 0
131137

132138
api = API()
133139
if __name__ == "__main__":

resources/settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
<setting label="32006" type="slider" id="scr-pct" default="70" range="0,100" option="percent" enable="gt(-1,-2)" />
1313
<setting label="32007" type="slider" id="sct-w-pct" default="10" range="0,100" option="
1414
percent"/>
15-
<setting label="32008" type="bool" id="bubble" default="false" enable="false"/>
15+
<setting label="32008" type="bool" id="bubble" default="false" enable="true"/>
1616
</category>
1717
</settings>

0 commit comments

Comments
 (0)