Skip to content

Commit 3105f5d

Browse files
committed
Fixing some styling issues
1 parent f5c2f31 commit 3105f5d

File tree

7 files changed

+349
-351
lines changed

7 files changed

+349
-351
lines changed

resources/lib/engine.py

Lines changed: 103 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,121 @@
11
#!/usr/bin/python
22
# -*- coding: UTF-8 -*-
33

4-
import xbmc, xbmcaddon
4+
import xbmc
55
import interface
66
import json
77
__addon__ = interface.__addon__
8-
def getstr(id): return interface.getstr(id)
8+
def getstr(strid): return interface.getstr(strid)
99

1010
class Engine:
11-
def __init__(self, api, player):
12-
self.api = api
13-
self.player = player
14-
player.engine = self
15-
player.api = api
16-
self.synclibrary()
11+
def __init__(self, api, player):
12+
self.api = api
13+
self.player = player
14+
player.engine = self
15+
player.api = api
16+
self.synclibrary()
1717

18-
def synclibrary(self):
19-
### UPLOAD ###
20-
#DISABLED UNTIL WORKING FINE
21-
pass
22-
'''
23-
kodilibrary = xbmc.executeJSONRPC(json.dumps({
24-
"jsonrpc": "2.0",
25-
"method": "VideoLibrary.GetMovies",
26-
"params": {
27-
28-
"limits": {
29-
"start": 0,
30-
"end": 1000
31-
},
32-
"properties": [
33-
"playcount",
34-
"imdbnumber",
35-
"file",
36-
"lastplayed"
37-
],
38-
"sort": {
39-
"order": "ascending",
40-
"method": "label",
41-
"ignorearticle": True
42-
}
43-
},
44-
"id": "libMovies"
45-
}))
46-
xbmc.log("Simkl: Ret: {}".format(kodilibrary))
47-
kodilibrary = json.loads(kodilibrary)
48-
49-
if kodilibrary["result"]["limits"]["total"] > 0:
50-
for movie in kodilibrary["result"]["movies"]:
51-
#Dont do that, upload all at once
18+
def synclibrary(self):
19+
### UPLOAD ###
20+
#DISABLED UNTIL WORKING FINE
21+
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)
47+
48+
if kodilibrary["result"]["limits"]["total"] > 0:
49+
for movie in kodilibrary["result"]["movies"]:
50+
#Dont do that, upload all at once
5251
53-
if movie["playcount"] > 0:
54-
imdb = movie["imdbnumber"]
55-
date = movie["lastplayed"]
56-
self.api.watched(imdb, "movie", date)
57-
'''
52+
if movie["playcount"] > 0:
53+
imdb = movie["imdbnumber"]
54+
date = movie["lastplayed"]
55+
self.api.watched(imdb, "movie", date)
56+
'''
5857

5958
class Player(xbmc.Player):
60-
def __init__(self):
61-
xbmc.Player.__init__(self)
59+
def __init__(self):
60+
xbmc.Player.__init__(self)
6261

63-
def getMediaType(self):
64-
if xbmc.getCondVisibility('Container.Content(tvshows)'):
65-
return "show"
66-
elif xbmc.getCondVisibility('Container.Content(seasons)'):
67-
return "season"
68-
elif xbmc.getCondVisibility('Container.Content(episodes)'):
69-
return "episode"
70-
elif xbmc.getCondVisibility('Container.Content(movies)'):
71-
return "movie"
72-
else:
73-
return None
62+
@classmethod
63+
def getMediaType(self):
64+
if xbmc.getCondVisibility('Container.Content(tvshows)'):
65+
return "show"
66+
elif xbmc.getCondVisibility('Container.Content(seasons)'):
67+
return "season"
68+
elif xbmc.getCondVisibility('Container.Content(episodes)'):
69+
return "episode"
70+
elif xbmc.getCondVisibility('Container.Content(movies)'):
71+
return "movie"
72+
else:
73+
return None
7474

75-
def onPlayBackStarted(self):
76-
self.onPlayBackStopped()
77-
def onPlayBackSeek(self, *args):
78-
#self.onPlayBackStopped()
79-
pass
80-
def onPlayBackResumed(self):
81-
#self.onPlayBackStopped()
82-
pass
83-
def onPlayBackEnded(self):
84-
xbmc.log("Simkl: ONPLAYBACKENDED")
85-
self.onPlayBackStopped()
86-
def onPlayBackStopped(self):
87-
try:
88-
movie = self.getVideoInfoTag()
89-
imdb = movie.getIMDBNumber().strip(" ")
90-
fname = self.getPlayingFile()
91-
thing = xbmc.executeJSONRPC(json.dumps({"jsonrpc": "2.0", "method": "Player.GetItem",
92-
"params": { "properties": [ "showtitle", "title" ]
93-
, "playerid": 1 }, "id": "VideoGetItem"}))
94-
xbmc.log("Simkl: Full: {}".format(thing))
95-
media = json.loads(thing)["result"]["item"]["type"]
96-
xbmc.log("Simkl: IMDb: {}".format(imdb))
97-
xbmc.log("Simkl: Genre: " + movie.getGenre())
98-
xbmc.log("Simkl: MediaType: " + str(media))
99-
#Scrobble from filename only for testing purposes or error of other methods
75+
def onPlayBackStarted(self):
76+
self.onPlayBackStopped()
77+
def onPlayBackSeek(self, *args):
78+
#self.onPlayBackStopped()
79+
pass
80+
def onPlayBackResumed(self):
81+
#self.onPlayBackStopped()
82+
pass
83+
def onPlayBackEnded(self):
84+
xbmc.log("Simkl: ONPLAYBACKENDED")
85+
self.onPlayBackStopped()
86+
def onPlayBackStopped(self):
87+
try:
88+
movie = self.getVideoInfoTag()
89+
imdb = movie.getIMDBNumber().strip(" ")
90+
fname = self.getPlayingFile()
91+
thing = xbmc.executeJSONRPC(json.dumps({"jsonrpc": "2.0", "method": "Player.GetItem",
92+
"params": { "properties": [ "showtitle", "title" ]
93+
, "playerid": 1 }, "id": "VideoGetItem"}))
94+
xbmc.log("Simkl: Full: {}".format(thing))
95+
media = json.loads(thing)["result"]["item"]["type"]
96+
xbmc.log("Simkl: IMDb: {}".format(imdb))
97+
xbmc.log("Simkl: Genre: " + movie.getGenre())
98+
xbmc.log("Simkl: MediaType: " + str(media))
99+
#Scrobble from filename only for testing purposes or error of other methods
100100

101-
percentage = 100 * self.getTime() / self.getTotalTime()
102-
pctconfig = int(self.addon.getSetting("scr-pct"))
103-
104-
if percentage > pctconfig:
105-
bubble = __addon__.getSetting("bubble")
101+
percentage = 100 * self.getTime() / self.getTotalTime()
102+
pctconfig = int(self.addon.getSetting("scr-pct"))
103+
104+
if percentage > pctconfig:
105+
bubble = __addon__.getSetting("bubble")
106106

107-
xbmc.log("Simkl: Ready to scrobble {}".format(movie.getTitle()))
108-
if imdb == "":
109-
xbmc.log("Simkl: No imdb - Fname: {}".format(fname))
110-
r = self.api.watched(fname, media, self.getTotalTime())
111-
else:
112-
xbmc.log("Simkl: IMDB: " + str(imdb))
113-
r = self.api.watched(imdb, media, self.getTotalTime())
107+
xbmc.log("Simkl: Ready to scrobble {}".format(movie.getTitle()))
108+
if imdb == "":
109+
xbmc.log("Simkl: No imdb - Fname: {}".format(fname))
110+
r = self.api.watched(fname, media, self.getTotalTime())
111+
else:
112+
xbmc.log("Simkl: IMDB: " + str(imdb))
113+
r = self.api.watched(imdb, media, self.getTotalTime())
114114

115-
if bubble and r:
116-
interface.notify(getstr(32028).format(
117-
json.loads(thing)["result"]["item"]["label"]))
118-
r = 0
115+
if bubble and r:
116+
interface.notify(getstr(32028).format(
117+
json.loads(thing)["result"]["item"]["label"]))
118+
r = 0
119119

120-
except RuntimeError:
121-
pass
120+
except RuntimeError:
121+
pass

resources/lib/interface.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,40 @@
66

77
__addon__ = xbmcaddon.Addon("script.simkl")
88
__icon__ = __addon__.getAddonInfo("icon")
9-
def getstr(id): return __addon__.getLocalizedString(id)
9+
def getstr(strid): return __addon__.getLocalizedString(strid)
1010

1111
xbmc.log("Simkl: Icon: "+str(__icon__))
1212

1313
not_dialog = xbmcgui.Dialog()
1414
def notify(txt="Test"):
15-
not_dialog.notification("Simkl", txt, __icon__) #Put an icon
15+
not_dialog.notification("Simkl", txt, __icon__) #Put an icon
16+
17+
#import simklapi
1618

17-
import simklapi
18-
1919
class loginDialog:
20-
def __init__(self, url, pin, check_login, log, exp=900, inter=5, api=None):
21-
#TODO: If user is loged in, show a confirmation dialog
22-
API = api
23-
self.dialog = xbmcgui.DialogProgress()
24-
self.dialog.create(getstr(32021),
25-
getstr(32022).format(url), "PIN: {}".format(pin))
26-
waiting = True
27-
cnt = 0
28-
while waiting:
29-
pct = min(max(1, int( round( cnt*100 / exp, 0))), 99)
30-
self.dialog.update(pct, line3=getstr(32023).format(
31-
str(cnt).zfill(3), exp))
20+
def __init__(self, url, pin, check_login, log, exp=900, inter=5, api=None):
21+
#TODO: If user is loged in, show a confirmation dialog
22+
API = api
23+
self.dialog = xbmcgui.DialogProgress()
24+
self.dialog.create(getstr(32021),
25+
getstr(32022).format(url), "PIN: {}".format(pin))
26+
waiting = True
27+
cnt = 0
28+
while waiting:
29+
pct = min(max(1, int( round( cnt*100 / exp, 0))), 99)
30+
self.dialog.update(pct, line3=getstr(32023).format(
31+
str(cnt).zfill(3), exp))
3232

33-
if cnt % (inter+1) == 0 and cnt>1:
34-
if check_login(pin,log):
35-
dialognot = xbmcgui.Dialog()
36-
xbmc.log(str(API.USERSETTINGS))
37-
dialognot.notification("Simkl", "Hello {}".format(
38-
API.USERSETTINGS["user"]["name"]))
39-
waiting = False
40-
pass #Now check the user has done what it has to be done
41-
time.sleep(1)
42-
cnt += 1
43-
if self.dialog.iscanceled() or cnt >= exp:
44-
waiting = False
45-
#raise Not logged in
33+
if cnt % (inter+1) == 0 and cnt>1:
34+
if check_login(pin,log):
35+
dialognot = xbmcgui.Dialog()
36+
xbmc.log(str(API.USERSETTINGS))
37+
dialognot.notification("Simkl", "Hello {}".format(
38+
API.USERSETTINGS["user"]["name"]))
39+
waiting = False
40+
#Now check the user has done what it has to be done
41+
time.sleep(1)
42+
cnt += 1
43+
if self.dialog.iscanceled() or cnt >= exp:
44+
waiting = False
45+
#raise Not logged in

0 commit comments

Comments
 (0)