From 357768997dd1f2ab229f0afd4d9dcab6cfcc930c Mon Sep 17 00:00:00 2001 From: jakewaldron Date: Tue, 28 Jun 2016 12:00:29 -0700 Subject: [PATCH] Bug Fix Handle cases where duration is not an integer by setting it to N/A. --- scripts/plexEmail.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/plexEmail.py b/scripts/plexEmail.py index 3e7a6df..68efd67 100644 --- a/scripts/plexEmail.py +++ b/scripts/plexEmail.py @@ -1423,14 +1423,18 @@ def exceptionHandler(type, value, tb): albums[album]['tracks'] = {} for row in cur2: - duration = row[5]/1000 - seconds = duration % 60 - duration /= 60 - minutes = duration % 60 - duration /= 60 - hours = duration - duration = str(hours) + ':' if (hours > 0) else '' - duration += str(minutes).zfill(2) + ':' + str(seconds).zfill(2) + duration = row[5] + try: + duration /= 1000 + seconds = duration % 60 + duration /= 60 + minutes = duration % 60 + duration /= 60 + hours = duration + duration = str(hours) + ':' if (hours > 0) else '' + duration += str(minutes).zfill(2) + ':' + str(seconds).zfill(2) + except TypeError: + duration = 'N/A' albums[album]['tracks'][row[4]] = {'id': row[0], 'title': row[1], 'title_sort': row[2], 'original_title': row[3], 'index': row[4], 'duration': duration, 'codec': row[6]} if ('album_sort_3' in config and config['album_sort_3'] != ''):