From cd6a0f6fe4111fc612dc949bcfaeaf55d3cf1557 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 1 Mar 2020 13:41:23 +0100 Subject: [PATCH] Fix TypeError: 'NoneType' object has no attribute '__getitem__' --- resources/lib/plex_api/file.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/resources/lib/plex_api/file.py b/resources/lib/plex_api/file.py index c3b561c9..ece2de17 100644 --- a/resources/lib/plex_api/file.py +++ b/resources/lib/plex_api/file.py @@ -69,18 +69,24 @@ class File(object): % self.grandparent_id()) else: path = 'plugin://%s/' % v.ADDON_TYPE[self.plex_type] - # Filename in Kodi will end with actual filename - hopefully - # this is useful for other add-ons - filename = self.file_path(force_first_media=force_first_media) - try: - if '/' in filename: - filename = filename.rsplit('/', 1)[1] - else: - filename = filename.rsplit('\\', 1)[1] - except (TypeError, IndexError): - return - entirepath = ('%s?mode=play&plex_id=%s&plex_type=%s&filename=%s' - % (path, self.plex_id, self.plex_type, filename)) + if self.plex_type in (v.PLEX_TYPE_MOVIE, + v.PLEX_TYPE_CLIP, + v.PLEX_TYPE_EPISODE): + # Filename in Kodi will end with actual filename - hopefully + # this is useful for other add-ons + filename = self.file_path(force_first_media=force_first_media) + try: + if '/' in filename: + filename = filename.rsplit('/', 1)[1] + else: + filename = filename.rsplit('\\', 1)[1] + except (TypeError, IndexError): + return + entirepath = ('%s?mode=play&plex_id=%s&plex_type=%s&filename=%s' + % (path, self.plex_id, self.plex_type, filename)) + else: + entirepath = ('%s?mode=play&plex_id=%s&plex_type=%s' + % (path, self.plex_id, self.plex_type)) # For Kodi DB, we need to safe the ENTIRE path for filenames filename = entirepath else: