From 50b25ccf73373c2459114bed3cefedca866c7d5d Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sat, 2 Apr 2016 10:43:50 +0200 Subject: [PATCH] Fix TypeError with PMS item 'addedAt' missing --- resources/lib/PlexAPI.py | 7 +++++-- resources/lib/utils.py | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index 8267d4bd..2d1623b7 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -1535,9 +1535,12 @@ class API(): def getDateCreated(self): """ - Returns the date when this library item was created + Returns the date when this library item was created or None """ - return utils.DateToKodi(self.item.attrib.get('addedAt')) + res = self.item.attrib.get('addedAt') + if res is not None: + res = utils.DateToKodi(res) + return res def getUserData(self): """ diff --git a/resources/lib/utils.py b/resources/lib/utils.py index bf1b4a4b..5dfd748f 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -32,9 +32,11 @@ def DateToKodi(stamp): propper, human-readable time stamp used by Kodi Output: Y-m-d h:m:s = 2009-04-05 23:16:04 + + None if an error was encountered """ - stamp = float(stamp) + float(window('kodiplextimeoffset')) try: + stamp = float(stamp) + float(window('kodiplextimeoffset')) date_time = time.localtime(stamp) localdate = time.strftime('%Y-%m-%d %H:%M:%S', date_time) except: