diff --git a/README.md b/README.md index 594a920..1356945 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Kodi ## Installing -1. Download the .zip [here](https://github.com/SIMKL/script.service.simkl/blob/master/script.service.simkl.zip) +1. Download the .zip [here](https://github.com/SIMKL/script.service.simkl/blob/master/script.simkl.zip) 2. Open Kodi and go to Settings > Add-ons > Install from zip file, select the zip file 3. In Settings > Add-ons > My add-ons and search for Simkl TV Tracker. Click on it. 4. Click on Configure to configure the add-on (Login and scrobbler options) diff --git a/addon.xml b/addon.xml index 2449249..d48f2ae 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ - diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 0000000..e664c29 --- /dev/null +++ b/changelog.txt @@ -0,0 +1,3 @@ +v0.1.1 (2016-12-23) +- Initial version +- Added notification bubble at scrobble \ No newline at end of file diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..d9b0b0d Binary files /dev/null and b/icon.png differ diff --git a/resources/language/English/strings.po b/resources/language/English/strings.po index edd0aaf..d2bbf27 100644 --- a/resources/language/English/strings.po +++ b/resources/language/English/strings.po @@ -53,7 +53,7 @@ msgid "Enter to the following URL: {}" msgstr "" msgctxt "#32023" -msgcid "Remaining time: {}/{}" +msgid "Remaining time: {}/{}" msgstr "" # Blahblahblah @@ -70,6 +70,10 @@ msgctxt "#32027" msgid "You don't have internet" msgstr "" +msgctxt "#32028" +msgid "Scrobbling {}" +msgstr "" + #msgctxt "#" #msgid "" #msgstr "" \ No newline at end of file diff --git a/resources/language/Spanish/strings.po b/resources/language/Spanish/strings.po index b242cb3..b5b1720 100644 --- a/resources/language/Spanish/strings.po +++ b/resources/language/Spanish/strings.po @@ -53,7 +53,7 @@ msgid "Enter to the following URL: {}" msgstr "Entra a la siguiente URL: {}" msgctxt "#32023" -msgcid "Remaining time: {}/{}" +msgid "Remaining time: {}/{}" msgstr "Tiempo restante: {}/{}" # Blahblahblah @@ -70,6 +70,10 @@ msgctxt "#32027" msgid "You don't have internet" msgstr "No tienes conexión a internet" +msgctxt "#32028" +msgid "Scrobbling {}" +msgstr "Scrobbling {}" + #msgctxt "#" #msgid "" #msgstr "" \ No newline at end of file diff --git a/resources/lib/engine.py b/resources/lib/engine.py index edc78bf..81ef773 100644 --- a/resources/lib/engine.py +++ b/resources/lib/engine.py @@ -4,6 +4,8 @@ import xbmc, xbmcaddon import interface import json +__addon__ = interface.__addon__ +def getstr(id): return interface.getstr(id) class Engine: def __init__(self, api, player): @@ -15,7 +17,9 @@ def __init__(self, api, player): def synclibrary(self): ### UPLOAD ### - + #DISABLED UNTIL WORKING FINE + pass + ''' kodilibrary = xbmc.executeJSONRPC(json.dumps({ "jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", @@ -41,6 +45,7 @@ def synclibrary(self): })) xbmc.log("Simkl: Ret: {}".format(kodilibrary)) kodilibrary = json.loads(kodilibrary) + if kodilibrary["result"]["limits"]["total"] > 0: for movie in kodilibrary["result"]["movies"]: #Dont do that, upload all at once @@ -49,6 +54,7 @@ def synclibrary(self): imdb = movie["imdbnumber"] date = movie["lastplayed"] self.api.watched(imdb, "movie", date) + ''' class Player(xbmc.Player): def __init__(self): @@ -82,10 +88,10 @@ def onPlayBackStopped(self): movie = self.getVideoInfoTag() imdb = movie.getIMDBNumber().strip(" ") fname = self.getPlayingFile() - media = xbmc.executeJSONRPC(json.dumps({"jsonrpc": "2.0", "method": "Player.GetItem", + thing = xbmc.executeJSONRPC(json.dumps({"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": [ "showtitle", "streamdetails","title"] , "playerid": 1 }, "id": "VideoGetItem"})) - media = json.loads(media)["result"]["item"]["type"] + media = json.loads(thing)["result"]["item"]["type"] xbmc.log("Simkl: IMDb: {}".format(imdb)) xbmc.log("Simkl: Genre: " + movie.getGenre()) xbmc.log("Simkl: MediaType: " + str(media)) @@ -95,13 +101,20 @@ def onPlayBackStopped(self): pctconfig = int(self.addon.getSetting("scr-pct")) if percentage > pctconfig: + bubble = __addon__.getSetting("bubble") + xbmc.log("Simkl: Ready to scrobble {}".format(movie.getTitle())) if imdb == "": xbmc.log("Simkl: No imdb - Fname: {}".format(fname)) - self.api.watched(fname, media) + r = self.api.watched(fname, media) #r from response else: xbmc.log("Simkl: IMDB: " + str(imdb)) - self.api.watched(imdb, media) + r = self.api.watched(imdb, media) + + if bubble and r: + xbmc.log("Simkl: Full: {}".format(thing)) + interface.notify(getstr(32028).format( + json.loads(thing)["result"]["item"]["label"])) except RuntimeError: pass diff --git a/resources/lib/interface.py b/resources/lib/interface.py index f22a383..18064f3 100644 --- a/resources/lib/interface.py +++ b/resources/lib/interface.py @@ -4,7 +4,7 @@ import time tmp = time.time() -__addon__ = xbmcaddon.Addon("script.service.simkl") +__addon__ = xbmcaddon.Addon("script.simkl") __icon__ = __addon__.getAddonInfo("icon") def getstr(id): return __addon__.getLocalizedString(id) diff --git a/resources/lib/simklapi.py b/resources/lib/simklapi.py index 38e9f72..7857134 100644 --- a/resources/lib/simklapi.py +++ b/resources/lib/simklapi.py @@ -13,6 +13,7 @@ import interface import httplib +__addon__ = interface.__addon__ def getstr(id): return interface.getstr(id) REDIRECT_URI = "http://simkl.com" @@ -123,11 +124,16 @@ def watched(self, filename, mediatype, date=time.strftime('%Y-%m-%d %H:%M:%S')): xbmc.log("Simkl: values {}".format(tosend)) con.request("GET", "/sync/history/", body=tosend, headers=headers) - xbmc.log("Simkl: {}".format(con.getresponse().read().decode("utf-8"))) + r = con.getresponse().read().decode("utf-8") + xbmc.log("Simkl: {}".format(r)) + + return max(json.loads(r)["added"].values()) + except httplib.BadStatusLine: xbmc.log("Simkl: {}".format("ERROR: httplib.BadStatusLine")) else: xbmc.log("Simkl: Can't scrobble. User not logged in") + return 0 api = API() if __name__ == "__main__": diff --git a/resources/settings.xml b/resources/settings.xml index f1c38ab..1a657bc 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -12,6 +12,6 @@ - + diff --git a/script.service.simkl.zip b/script.service.simkl.zip deleted file mode 100644 index 78d3900..0000000 Binary files a/script.service.simkl.zip and /dev/null differ diff --git a/script.simkl.zip b/script.simkl.zip new file mode 100644 index 0000000..d2ce281 Binary files /dev/null and b/script.simkl.zip differ diff --git a/tozip.sh b/tozip.sh index 8beb1ff..5747849 100755 --- a/tozip.sh +++ b/tozip.sh @@ -1,9 +1,9 @@ #!/bin/bash #Creates a zip file compatible with Kodi -mkdir script.service.simkl -rsync -rv --progress ./ ./script.service.simkl --exclude-from .gitignore --exclude tozip.sh +mkdir script.simkl +rsync -rv --progress ./ ./script.simkl --exclude-from .gitignore --exclude tozip.sh -rm script.service.simkl.zip -zip -rx@.gitignore script.service.simkl.zip script.service.simkl/* -rm -Rf script.service.simkl +rm script.simkl.zip +zip -rx@.gitignore script.simkl.zip script.simkl/* +rm -Rf script.simkl