Reorganize get user/library details

This commit is contained in:
JonnyWong16 2021-03-22 10:29:35 -07:00
parent 1ff6a54d70
commit 7ebed4ffd7
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 134 additions and 131 deletions

View file

@ -796,7 +796,32 @@ class Libraries(object):
if server_id is None:
server_id = plexpy.CONFIG.PMS_IDENTIFIER
def get_library_details(section_id=section_id, server_id=server_id):
library_details = self.get_library_details(section_id=section_id, server_id=server_id)
if library_details:
return library_details
else:
logger.warn("Tautulli Libraries :: Unable to retrieve library %s from database. Requesting library list refresh."
% section_id)
# Let's first refresh the libraries list to make sure the library isn't newly added and not in the db yet
refresh_libraries()
library_details = self.get_library_details(section_id=section_id, server_id=server_id)
if library_details:
return library_details
else:
logger.warn("Tautulli Users :: Unable to retrieve library %s from database. Returning 'Local' library."
% section_id)
# If there is no library data we must return something
return default_return
def get_library_details(self, section_id=None, server_id=None):
if server_id is None:
server_id = plexpy.CONFIG.PMS_IDENTIFIER
monitor_db = database.MonitorDatabase()
try:
@ -848,28 +873,6 @@ class Libraries(object):
}
return library_details
library_details = get_library_details(section_id=section_id, server_id=server_id)
if library_details:
return library_details
else:
logger.warn("Tautulli Libraries :: Unable to retrieve library %s from database. Requesting library list refresh."
% section_id)
# Let's first refresh the libraries list to make sure the library isn't newly added and not in the db yet
refresh_libraries()
library_details = get_library_details(section_id=section_id, server_id=server_id)
if library_details:
return library_details
else:
logger.warn("Tautulli Users :: Unable to retrieve library %s from database. Returning 'Local' library."
% section_id)
# If there is no library data we must return something
return default_return
def get_watch_time_stats(self, section_id=None, grouping=None, query_days=None):
if not session.allow_session_library(section_id):
return []

View file

@ -381,7 +381,30 @@ class Users(object):
if user_id is None and not user and not email:
return default_return
def get_user_details(user_id=user_id, user=user, email=email):
user_details = self.get_user_details(user_id=user_id, user=user, email=email)
if user_details:
return user_details
else:
logger.warn("Tautulli Users :: Unable to retrieve user %s from database. Requesting user list refresh."
% user_id if user_id else user)
# Let's first refresh the user list to make sure the user isn't newly added and not in the db yet
refresh_users()
user_details = self.get_user_details(user_id=user_id, user=user, email=email)
if user_details:
return user_details
else:
logger.warn("Tautulli Users :: Unable to retrieve user %s from database. Returning 'Local' user."
% user_id if user_id else user)
# If there is no user data we must return something
# Use "Local" user to retain compatibility with PlexWatch database value
return default_return
def get_user_details(self, user_id=None, user=None, email=None):
monitor_db = database.MonitorDatabase()
try:
@ -456,29 +479,6 @@ class Users(object):
}
return user_details
user_details = get_user_details(user_id=user_id, user=user)
if user_details:
return user_details
else:
logger.warn("Tautulli Users :: Unable to retrieve user %s from database. Requesting user list refresh."
% user_id if user_id else user)
# Let's first refresh the user list to make sure the user isn't newly added and not in the db yet
refresh_users()
user_details = get_user_details(user_id=user_id, user=user)
if user_details:
return user_details
else:
logger.warn("Tautulli Users :: Unable to retrieve user %s from database. Returning 'Local' user."
% user_id if user_id else user)
# If there is no user data we must return something
# Use "Local" user to retain compatibility with PlexWatch database value
return default_return
def get_watch_time_stats(self, user_id=None, grouping=None, query_days=None):
if not session.allow_session_user(user_id):
return []