From 31a25ba2d560a95cbde7c61b5d837279d4e0eba4 Mon Sep 17 00:00:00 2001 From: "Francisco Blas (klondike) Izquierdo Riera" Date: Mon, 28 Jan 2019 22:38:07 +0100 Subject: [PATCH] fix: exception breaking reproductions when playcount missing Sometimes the netflix plugin marks an episode as not seen and deletes the playcount field. This makes watching the episode or film impossible as when creating the infos object this field is accessed. Here is an example exception. ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<-- - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! Error Type: Error Contents: 'playcount' Traceback (most recent call last): File "/storage/.kodi/addons/plugin.video.netflix/addon.py", line 33, in NAVIGATION.router(paramstring=REQUEST_PARAMS) File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/utils.py", line 60, in wrapped result = func(*args, **kwargs) File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/Navigation.py", line 253, in router infoLabels=params.get('infoLabels', {})) File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/utils.py", line 60, in wrapped result = func(*args, **kwargs) File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/Navigation.py", line 313, in play_video timeline_markers=self._get_timeline_markers(metadata)) File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/KodiHelper.py", line 986, in play_item 'playcount': details[0]['playcount']}}) KeyError: 'playcount' -->End of Python script error report<-- Instead we use the dictionary get method so that we can fall back to 0 when the attribute is absent. --- resources/lib/KodiHelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lib/KodiHelper.py b/resources/lib/KodiHelper.py index c0503e228..6c33a5989 100644 --- a/resources/lib/KodiHelper.py +++ b/resources/lib/KodiHelper.py @@ -983,7 +983,7 @@ def play_item(self, video_id, start_offset=-1, infoLabels={}, tvshow_video_id=No 'dbinfo': { 'dbid': details[0]['dbid'], 'dbtype': details[0]['mediatype'], - 'playcount': details[0]['playcount']}}) + 'playcount': details[0].get('playcount',0)}}) if infoLabels['mediatype'] == 'episode': signal_data['dbinfo'].update({'tvshowid': id[0]})