diff --git a/resources/lib/LibrarySync.py b/resources/lib/LibrarySync.py index edec389a..de48ee85 100644 --- a/resources/lib/LibrarySync.py +++ b/resources/lib/LibrarySync.py @@ -495,9 +495,11 @@ class LibrarySync(): #add all kodi episodes to a list with episodes for use later on to delete episodes #the mediabrowser ID is set as uniqueID in the NFO... for some reason this has key 'unknown' in the json response - for episode in ReadKodiDB().getKodiEpisodes(tvshow,False,False): - dict = {'mbid': str(episode["uniqueid"]["unknown"]),'kodiid': str(episode["episodeid"])} - allKodiEpisodeIds.append(dict) + show = ReadKodiDB().getKodiEpisodes(tvshow,False,False) + if show != None: + for episode in show: + dict = {'mbid': str(episode["uniqueid"]["unknown"]),'kodiid': str(episode["episodeid"])} + allKodiEpisodeIds.append(dict) showCurrent += 1 diff --git a/resources/lib/WriteKodiDB.py b/resources/lib/WriteKodiDB.py index c9696e6f..7c4aa701 100644 --- a/resources/lib/WriteKodiDB.py +++ b/resources/lib/WriteKodiDB.py @@ -424,21 +424,22 @@ class WriteKodiDB(): utils.logMsg("deleting episode from Kodi library",episodeid) json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodeDetails", "params": { "episodeid": %i}, "properties" : ["file","episodeid"] }, "id": 1}' %(int(episodeid))) - jsonobject = json.loads(json_response.decode('utf-8','replace')) + if json_response != None and json_response != "" and json_response != []: + jsonobject = json.loads(json_response.decode('utf-8','replace')) - print jsonobject - if(jsonobject.has_key('result')): - result = jsonobject['result'] - if(result.has_key('episodedetails')): - episodedetails = result['episodedetails'] + print jsonobject + if(jsonobject.has_key('result')): + result = jsonobject['result'] + if(result.has_key('episodedetails')): + episodedetails = result['episodedetails'] - strmfile = episodedetails["file"] - nfofile = strmfile.replace(".strm",".nfo") + strmfile = episodedetails["file"] + nfofile = strmfile.replace(".strm",".nfo") - xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.RemoveEpisode", "params": { "episodeid": %i}, "id": 1 }' %(int(episodeid))) + xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.RemoveEpisode", "params": { "episodeid": %i}, "id": 1 }' %(int(episodeid))) - xbmcvfs.delete(strmfile) - xbmcvfs.delete(nfofile) + xbmcvfs.delete(strmfile) + xbmcvfs.delete(nfofile) def addTVShowToKodiLibrary( self, item ): itemPath = os.path.join(tvLibrary,item["Id"])