-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Since a few months the synchronisation between Kodi and TVShow Time was broken for an unkown reason.
After a quick look at the log file (/home/osmc/.kodi/temp/kodi.log) I find out the following message when a new episode was checked :
17:35:41.397 T:1703809792 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.KeyError'>
Error Contents: ('unknown',)
Traceback (most recent call last):
File "/home/osmc/.kodi/addons/script.tvshowtime/default.py", line 202, in onNotification
item = self.getEpisodeTVDB(xbmc_id)
File "/home/osmc/.kodi/addons/script.tvshowtime/default.py", line 270, in getEpisodeTVDB
log('episode_id=%s' % result['result']['episodedetails']['uniqueid']['unknown'])
KeyError: ('unknown',)
-->End of Python script error report<--
After a quick look at the /home/osmc/.kodi/addons/script.tvshowtime/default.py file I found the following strange lines :
def getEpisodeTVDB(self, xbmc_id):
rpccmd = {'jsonrpc': '2.0', 'method': 'VideoLibrary.GetEpisodeDetails', 'params': {"episodeid": int(xbmc_id), 'properties': ['season', 'episode', 'tvshowid', 'showtitle', 'uniqueid']}, 'id': 1}
rpccmd = json.dumps(rpccmd)
result = xbmc.executeJSONRPC(rpccmd)
result = json.loads(result)
log('result=%s' % result)
log('episode_id=%s' % result['result']['episodedetails']['uniqueid']['unknown'])
try:
item = {}
item['season'] = result['result']['episodedetails']['season']
item['tvshowid'] = result['result']['episodedetails']['tvshowid']
item['episode'] = result['result']['episodedetails']['episode']
item['showtitle'] = result['result']['episodedetails']['showtitle']
item['episode_id'] = result['result']['episodedetails']['uniqueid']['unknown']
return item
except:
return False
The strange part was the "unkown" parameter. I don't know why it was written this way at first but anyway, the result object have the following structure :
result={u'jsonrpc': u'2.0', u'id': 1, u'result': {u'episodedetails': {u'tvshowid': 51, u'episode': 8, u'season': 3, u'episodeid': 3486, u'label': u'Les souvenirs effac\xe9s de Morty', u'uniqueid': {u'tvdb': u'6288260', u'imdb': u'tt5218350'}, u'showtitle': u'Rick et Morty'}}}
As we can see the 'unique_id' sub-dictionary have two values ('tvdb' and 'imdb') but no 'unkwon' key...
To fix my issue I just changed the result['result']['episodedetails']['uniqueid']['unknown'] by result['result']['episodedetails']['uniqueid']['tvdb'] in the upper function (lines 269 and 277).
And now it works !
Not sure if this 'unknown' key is a bug for everybody or just some happy few, but it's been a long time I've been looking for a fix (probably since the last TVShow time plugin update).