Enable keep_history for default user/library

* Log sessions to "Local" if retrieving user/library data fails
This commit is contained in:
JonnyWong16 2016-03-05 16:21:59 -08:00
parent 5652a2b6c2
commit c5b2b86786
2 changed files with 12 additions and 9 deletions

View file

@ -539,7 +539,7 @@ class Libraries(object):
def get_details(self, section_id=None): def get_details(self, section_id=None):
from plexpy import pmsconnect from plexpy import pmsconnect
default_return = {'section_id': None, default_return = {'section_id': 0,
'section_name': 'Local', 'section_name': 'Local',
'section_type': '', 'section_type': '',
'library_thumb': common.DEFAULT_COVER_THUMB, 'library_thumb': common.DEFAULT_COVER_THUMB,
@ -549,7 +549,7 @@ class Libraries(object):
'child_count': 0, 'child_count': 0,
'do_notify': 0, 'do_notify': 0,
'do_notify_created': 0, 'do_notify_created': 0,
'keep_history': 0 'keep_history': 1
} }
if not section_id: if not section_id:
@ -602,7 +602,8 @@ class Libraries(object):
return library_details return library_details
else: else:
logger.warn(u"PlexPy Libraries :: Unable to retrieve library from local database. Requesting library list refresh.") logger.warn(u"PlexPy 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 # Let's first refresh the libraries list to make sure the library isn't newly added and not in the db yet
pmsconnect.refresh_libraries() pmsconnect.refresh_libraries()
@ -612,9 +613,9 @@ class Libraries(object):
return library_details return library_details
else: else:
logger.warn(u"PlexPy Users :: Unable to retrieve user from local database. Returning 'Local' library.") logger.warn(u"PlexPy Users :: Unable to retrieve library %s from database. Returning 'Local' library."
% section_id)
# If there is no library data we must return something # If there is no library data we must return something
# Use "Local" library to retain compatibility with PlexWatch database value
return default_return return default_return
def get_watch_time_stats(self, section_id=None): def get_watch_time_stats(self, section_id=None):

View file

@ -241,7 +241,7 @@ class Users(object):
def get_details(self, user_id=None, user=None): def get_details(self, user_id=None, user=None):
from plexpy import plextv from plexpy import plextv
default_return = {'user_id': None, default_return = {'user_id': 0,
'username': 'Local', 'username': 'Local',
'friendly_name': 'Local', 'friendly_name': 'Local',
'user_thumb': common.DEFAULT_USER_THUMB, 'user_thumb': common.DEFAULT_USER_THUMB,
@ -250,7 +250,7 @@ class Users(object):
'is_allow_sync': 0, 'is_allow_sync': 0,
'is_restricted': 0, 'is_restricted': 0,
'do_notify': 0, 'do_notify': 0,
'keep_history': 0 'keep_history': 1
} }
if not user_id and not user: if not user_id and not user:
@ -312,7 +312,8 @@ class Users(object):
return user_details return user_details
else: else:
logger.warn(u"PlexPy Users :: Unable to retrieve user from local database. Requesting user list refresh.") logger.warn(u"PlexPy 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 # Let's first refresh the user list to make sure the user isn't newly added and not in the db yet
plextv.refresh_users() plextv.refresh_users()
@ -322,7 +323,8 @@ class Users(object):
return user_details return user_details
else: else:
logger.warn(u"PlexPy Users :: Unable to retrieve user from local database. Returning 'Local' user.") logger.warn(u"PlexPy 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 # If there is no user data we must return something
# Use "Local" user to retain compatibility with PlexWatch database value # Use "Local" user to retain compatibility with PlexWatch database value
return default_return return default_return