mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -07:00
Fix some exception handling.
This commit is contained in:
parent
7a5cad1a31
commit
857e9e9d1c
3 changed files with 45 additions and 32 deletions
|
@ -115,10 +115,13 @@ def convert_milliseconds(ms):
|
||||||
|
|
||||||
def convert_milliseconds_to_minutes(ms):
|
def convert_milliseconds_to_minutes(ms):
|
||||||
|
|
||||||
seconds = float(ms) / 1000
|
if ms.isdigit():
|
||||||
minutes = round(seconds / 60, 0)
|
seconds = float(ms) / 1000
|
||||||
|
minutes = round(seconds / 60, 0)
|
||||||
|
|
||||||
return math.trunc(minutes)
|
return math.trunc(minutes)
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
def convert_seconds(s):
|
def convert_seconds(s):
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ class HTTPHandler(object):
|
||||||
return output
|
return output
|
||||||
else:
|
else:
|
||||||
logger.warn(u"Failed to access uri endpoint %s. Status code %r" % (uri, request_status))
|
logger.warn(u"Failed to access uri endpoint %s. Status code %r" % (uri, request_status))
|
||||||
return []
|
return None
|
||||||
else:
|
else:
|
||||||
logger.debug(u"HTTP request made but no enpoint given.")
|
logger.debug(u"HTTP request made but no enpoint given.")
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -186,12 +186,14 @@ class PmsConnect(object):
|
||||||
"""
|
"""
|
||||||
def get_recently_added_details(self, count='0'):
|
def get_recently_added_details(self, count='0'):
|
||||||
recent = self.get_recently_added(count, output_format='xml')
|
recent = self.get_recently_added(count, output_format='xml')
|
||||||
recents_list = []
|
|
||||||
|
|
||||||
xml_head = recent.getElementsByTagName('MediaContainer')
|
try:
|
||||||
if not xml_head:
|
xml_head = recent.getElementsByTagName('MediaContainer')
|
||||||
logger.warn("Error parsing XML for Plex recently added.")
|
except:
|
||||||
return None
|
logger.warn("Unable to parse XML for get_recently_added.")
|
||||||
|
return []
|
||||||
|
|
||||||
|
recents_list = []
|
||||||
|
|
||||||
for a in xml_head:
|
for a in xml_head:
|
||||||
if a.getAttribute('size'):
|
if a.getAttribute('size'):
|
||||||
|
@ -245,12 +247,14 @@ class PmsConnect(object):
|
||||||
"""
|
"""
|
||||||
def get_metadata_details(self, rating_key=''):
|
def get_metadata_details(self, rating_key=''):
|
||||||
metadata = self.get_metadata(rating_key, output_format='xml')
|
metadata = self.get_metadata(rating_key, output_format='xml')
|
||||||
metadata_list = []
|
|
||||||
|
|
||||||
xml_head = metadata.getElementsByTagName('MediaContainer')
|
try:
|
||||||
if not xml_head:
|
xml_head = metadata.getElementsByTagName('MediaContainer')
|
||||||
logger.warn("Error parsing XML for Plex metadata.")
|
except:
|
||||||
return None
|
logger.warn("Unable to parse XML for get_metadata.")
|
||||||
|
return []
|
||||||
|
|
||||||
|
metadata_list = []
|
||||||
|
|
||||||
for a in xml_head:
|
for a in xml_head:
|
||||||
if a.getAttribute('size'):
|
if a.getAttribute('size'):
|
||||||
|
@ -398,12 +402,14 @@ class PmsConnect(object):
|
||||||
"""
|
"""
|
||||||
def get_current_activity(self):
|
def get_current_activity(self):
|
||||||
session_data = self.get_sessions(output_format='xml')
|
session_data = self.get_sessions(output_format='xml')
|
||||||
session_list = []
|
|
||||||
|
|
||||||
xml_head = session_data.getElementsByTagName('MediaContainer')
|
try:
|
||||||
if not xml_head:
|
xml_head = session_data.getElementsByTagName('MediaContainer')
|
||||||
logger.warn("Error parsing XML for Plex session data.")
|
except:
|
||||||
return None
|
logger.warn("Unable to parse XML for get_sessions.")
|
||||||
|
return []
|
||||||
|
|
||||||
|
session_list = []
|
||||||
|
|
||||||
for a in xml_head:
|
for a in xml_head:
|
||||||
if a.getAttribute('size'):
|
if a.getAttribute('size'):
|
||||||
|
@ -645,12 +651,14 @@ class PmsConnect(object):
|
||||||
"""
|
"""
|
||||||
def get_season_children(self, rating_key=''):
|
def get_season_children(self, rating_key=''):
|
||||||
episode_data = self.get_episode_list(rating_key, output_format='xml')
|
episode_data = self.get_episode_list(rating_key, output_format='xml')
|
||||||
episode_list = []
|
|
||||||
|
|
||||||
xml_head = episode_data.getElementsByTagName('MediaContainer')
|
try:
|
||||||
if not xml_head:
|
xml_head = episode_data.getElementsByTagName('MediaContainer')
|
||||||
logger.warn("Error parsing XML for Plex session data.")
|
except:
|
||||||
return None
|
logger.warn("Unable to parse XML for get_episode_list.")
|
||||||
|
return []
|
||||||
|
|
||||||
|
episode_list = []
|
||||||
|
|
||||||
for a in xml_head:
|
for a in xml_head:
|
||||||
if a.getAttribute('size'):
|
if a.getAttribute('size'):
|
||||||
|
@ -686,10 +694,11 @@ class PmsConnect(object):
|
||||||
def get_servers_info(self):
|
def get_servers_info(self):
|
||||||
recent = self.get_server_list(output_format='xml')
|
recent = self.get_server_list(output_format='xml')
|
||||||
|
|
||||||
xml_head = recent.getElementsByTagName('Server')
|
try:
|
||||||
if not xml_head:
|
xml_head = recent.getElementsByTagName('Server')
|
||||||
logger.warn("Error parsing XML for Plex server prefs.")
|
except:
|
||||||
return None
|
logger.warn("Unable to parse XML for get_server_list.")
|
||||||
|
return []
|
||||||
|
|
||||||
server_info = []
|
server_info = []
|
||||||
for a in xml_head:
|
for a in xml_head:
|
||||||
|
@ -712,10 +721,11 @@ class PmsConnect(object):
|
||||||
def get_server_identity(self):
|
def get_server_identity(self):
|
||||||
identity = self.get_local_server_identity(output_format='xml')
|
identity = self.get_local_server_identity(output_format='xml')
|
||||||
|
|
||||||
xml_head = identity.getElementsByTagName('MediaContainer')
|
try:
|
||||||
if not xml_head:
|
xml_head = identity.getElementsByTagName('MediaContainer')
|
||||||
logger.warn("Error parsing XML for Plex server identity.")
|
except:
|
||||||
return None
|
logger.warn("Unable to parse XML for get_local_server_identity.")
|
||||||
|
return []
|
||||||
|
|
||||||
server_identity = {}
|
server_identity = {}
|
||||||
for a in xml_head:
|
for a in xml_head:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue