mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -07:00
Return default ip_address/poster_url if database query fails
This commit is contained in:
parent
2a885d709d
commit
00b6bf8394
1 changed files with 22 additions and 14 deletions
|
@ -843,14 +843,18 @@ class DataFactory(object):
|
||||||
def get_session_ip(self, session_key=''):
|
def get_session_ip(self, session_key=''):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if session_key:
|
|
||||||
query = 'SELECT ip_address FROM sessions WHERE session_key = %d' % int(session_key)
|
|
||||||
result = monitor_db.select(query)
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
ip_address = 'N/A'
|
ip_address = 'N/A'
|
||||||
|
|
||||||
|
if session_key:
|
||||||
|
try:
|
||||||
|
query = 'SELECT ip_address FROM sessions WHERE session_key = %d' % int(session_key)
|
||||||
|
result = monitor_db.select(query)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn(u"PlexPy DataFactory :: Unable to execute database query for get_session_ip: %s." % e)
|
||||||
|
return ip_address
|
||||||
|
else:
|
||||||
|
return ip_address
|
||||||
|
|
||||||
for item in result:
|
for item in result:
|
||||||
ip_address = item['ip_address']
|
ip_address = item['ip_address']
|
||||||
|
|
||||||
|
@ -859,16 +863,20 @@ class DataFactory(object):
|
||||||
def get_poster_url(self, rating_key=''):
|
def get_poster_url(self, rating_key=''):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if rating_key:
|
|
||||||
query = 'SELECT id, poster_url FROM notify_log ' \
|
|
||||||
'WHERE rating_key = %d OR parent_rating_key = %d OR grandparent_rating_key = %d ' \
|
|
||||||
'ORDER BY id DESC LIMIT 1' % (int(rating_key), int(rating_key), int(rating_key))
|
|
||||||
result = monitor_db.select(query)
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
poster_url = ''
|
poster_url = ''
|
||||||
|
|
||||||
|
if rating_key:
|
||||||
|
try:
|
||||||
|
query = 'SELECT id, poster_url FROM notify_log ' \
|
||||||
|
'WHERE rating_key = %d OR parent_rating_key = %d OR grandparent_rating_key = %d ' \
|
||||||
|
'ORDER BY id DESC LIMIT 1' % (int(rating_key), int(rating_key), int(rating_key))
|
||||||
|
result = monitor_db.select(query)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn(u"PlexPy DataFactory :: Unable to execute database query for get_poster_url: %s." % e)
|
||||||
|
return poster_url
|
||||||
|
else:
|
||||||
|
return poster_url
|
||||||
|
|
||||||
for item in result:
|
for item in result:
|
||||||
poster_url = item['poster_url']
|
poster_url = item['poster_url']
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue