Skip to content

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
Handle cases where duration is not an integer by setting it to N/A.
  • Loading branch information
jakewaldron committed Jun 28, 2016
1 parent 6b2c7a1 commit 3577689
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions scripts/plexEmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'] != ''):
Expand Down

0 comments on commit 3577689

Please sign in to comment.