mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -07:00
Fix regression where duration not reported as min
This commit is contained in:
parent
eeb351e991
commit
0b301fff3f
2 changed files with 9 additions and 9 deletions
|
@ -378,14 +378,14 @@ def create_https_certificates(ssl_cert, ssl_key):
|
|||
def cast_to_int(s):
|
||||
try:
|
||||
return int(s)
|
||||
except ValueError:
|
||||
return -1
|
||||
except (ValueError, TypeError):
|
||||
return 0
|
||||
|
||||
def cast_to_float(s):
|
||||
try:
|
||||
return float(s)
|
||||
except ValueError:
|
||||
return -1
|
||||
except (ValueError, TypeError):
|
||||
return 0
|
||||
|
||||
def convert_xml_to_json(xml):
|
||||
o = xmltodict.parse(xml)
|
||||
|
|
|
@ -354,7 +354,7 @@ def build_notify_text(session=None, timeline=None, state=None):
|
|||
|
||||
if server_times:
|
||||
updated_at = server_times[0]['updated_at']
|
||||
server_uptime = helpers.human_duration(int(time.time() - helpers.cast_to_float(updated_at)))
|
||||
server_uptime = helpers.human_duration(int(time.time() - helpers.cast_to_int(updated_at)))
|
||||
else:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to retrieve server uptime.")
|
||||
server_uptime = 'N/A'
|
||||
|
@ -448,8 +448,8 @@ def build_notify_text(session=None, timeline=None, state=None):
|
|||
if state != 'play':
|
||||
stream_duration = helpers.convert_seconds_to_minutes(
|
||||
time.time() -
|
||||
helpers.cast_to_float(session.get('started', 0)) -
|
||||
helpers.cast_to_float(session.get('paused_counter', 0)))
|
||||
helpers.cast_to_int(session.get('started', 0)) -
|
||||
helpers.cast_to_int(session.get('paused_counter', 0)))
|
||||
else:
|
||||
stream_duration = 0
|
||||
|
||||
|
@ -537,7 +537,7 @@ def build_notify_text(session=None, timeline=None, state=None):
|
|||
'summary': metadata['summary'],
|
||||
'tagline': metadata['tagline'],
|
||||
'rating': metadata['rating'],
|
||||
'duration': metadata['duration'],
|
||||
'duration': duration,
|
||||
'section_id': metadata['section_id'],
|
||||
'rating_key': metadata['rating_key'],
|
||||
'parent_rating_key': metadata['parent_rating_key'],
|
||||
|
@ -742,7 +742,7 @@ def build_server_notify_text(state=None):
|
|||
|
||||
if server_times:
|
||||
updated_at = server_times[0]['updated_at']
|
||||
server_uptime = helpers.human_duration(int(time.time() - helpers.cast_to_float(updated_at)))
|
||||
server_uptime = helpers.human_duration(int(time.time() - helpers.cast_to_int(updated_at)))
|
||||
else:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to retrieve server uptime.")
|
||||
server_uptime = 'N/A'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue