44import xbmc , xbmcaddon
55import interface
66import json
7+ __addon__ = interface .__addon__
8+ def getstr (id ): return interface .getstr (id )
79
810class 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
5359class 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
0 commit comments