fixed empty results in getKodiTvshow and GetKodiMovie

filter in kodi api call doesn't accept all fields as searchparameter so walk through the results instead
This commit is contained in:
Marcel van der Veldt 2015-03-29 22:13:11 +02:00
parent 526e079f44
commit a796ced05c
2 changed files with 16 additions and 5 deletions

View file

@ -20,10 +20,11 @@ musicvideoLibrary = os.path.join(dataPath,'musicvideos')
sleepVal = 15 sleepVal = 15
class ReadKodiDB(): class ReadKodiDB():
def getKodiMovie(self, id): def getKodiMovie(self, id):
#returns a single movie from Kodi db selected on MB item ID #returns a single movie from Kodi db selected on MB item ID
xbmc.sleep(sleepVal) xbmc.sleep(sleepVal)
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": {"operator": "contains", "field": "imdbnumber ", "value": "' + id + '"}, "properties" : ["art", "rating", "thumbnail", "resume", "runtime", "year", "genre", "cast", "trailer", "country", "studio", "set", "imdbnumber", "mpaa", "tagline", "plotoutline","plot", "sorttitle", "director", "lastplayed", "writer", "playcount", "tag", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libMovies"}') json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "properties" : ["art", "rating", "thumbnail", "resume", "runtime", "year", "genre", "cast", "trailer", "country", "studio", "set", "imdbnumber", "mpaa", "tagline", "plotoutline","plot", "sorttitle", "director", "lastplayed", "writer", "playcount", "tag", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libMovies"}')
jsonobject = json.loads(json_response.decode('utf-8','replace')) jsonobject = json.loads(json_response.decode('utf-8','replace'))
movie = None movie = None
@ -32,7 +33,10 @@ class ReadKodiDB():
if(result.has_key('movies')): if(result.has_key('movies')):
movies = result['movies'] movies = result['movies']
movie = movies[0] movie = movies[0]
for item in movies:
if item["imdbnumber"] == id:
movie = item
break
return movie return movie
def getEmbyIdByKodiId(self, kodiid, type): def getEmbyIdByKodiId(self, kodiid, type):
@ -149,14 +153,17 @@ class ReadKodiDB():
def getKodiTVShow(self, id): def getKodiTVShow(self, id):
xbmc.sleep(sleepVal) xbmc.sleep(sleepVal)
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "filter": {"operator": "is", "field": "imdbnumber", "value": "' + id + '"}, "properties": ["art", "genre", "plot", "mpaa", "cast", "studio", "sorttitle", "title", "originaltitle", "imdbnumber", "year", "lastplayed", "premiered", "rating", "thumbnail", "playcount", "file", "fanart"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}') json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "properties": ["art", "genre", "plot", "mpaa", "cast", "studio", "sorttitle", "title", "originaltitle", "imdbnumber", "year", "lastplayed", "premiered", "rating", "thumbnail", "playcount", "file", "fanart"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}')
jsonobject = json.loads(json_response.decode('utf-8','replace')) jsonobject = json.loads(json_response.decode('utf-8','replace'))
tvshow = None tvshow = None
if(jsonobject.has_key('result')): if(jsonobject.has_key('result')):
result = jsonobject['result'] result = jsonobject['result']
if(result.has_key('tvshows')): if(result.has_key('tvshows')):
tvshows = result['tvshows'] tvshows = result['tvshows']
tvshow = tvshows[0] for show in tvshows:
if show["imdbnumber"] == id:
tvshow = show
break
return tvshow return tvshow
def getKodiEpisodes(self, KodiTvShowId, fullInfo = True, returnmap = True): def getKodiEpisodes(self, KodiTvShowId, fullInfo = True, returnmap = True):

View file

@ -770,7 +770,11 @@ class WriteKodiDB():
xbmcvfs.delete(nfofile) xbmcvfs.delete(nfofile)
while WINDOW.getProperty("suspendDeletes") == "True": while WINDOW.getProperty("suspendDeletes") == "True":
xbmc.sleep(100) xbmc.sleep(100)
utils.logMsg("episode deleted succesfully!",episodeid)
else:
utils.logMsg("episode not found in kodi DB",episodeid)
def addTVShowToKodiLibrary( self, item ): def addTVShowToKodiLibrary( self, item ):
itemPath = os.path.join(tvLibrary,item["Id"]) itemPath = os.path.join(tvLibrary,item["Id"])